- 积分
- 256
- 明经币
- 个
- 注册时间
- 2024-1-19
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
本帖最后由 as6424 于 2024-2-1 08:42 编辑
- <div style="color: rgb(204, 204, 204); background-color: rgb(31, 31, 31); font-family: Consolas, "Courier New", monospace; line-height: 19px; white-space: pre;">
- <div>(<span style="color: #569cd6;">vl-load-com</span>)
- (<span style="color: #569cd6;">defun</span> c:oo (/ oo_ss ss_length temp_i ss_i_ename ename_list p3_nth)
- <span style="color: #6a9955;">;or 判断是否需要切换图层,输入则切换,无输入则保持</span>
- (<span style="color: #569cd6;">setq</span> oo_py_fs_str (<span style="color: #569cd6;">getstring</span> <span style="color: #ce9178;">"\nn/w"</span>))
-
- (<span style="color: #569cd6;">if</span> (<span style="color: #569cd6;">not</span> oo_py_dict)
- (<span style="color: #569cd6;">setq</span> oo_py_dict <span style="color: #b5cea8;">0</span>))
-
- (<span style="color: #569cd6;">setq</span> oo_py_dict_s (<span style="color: #569cd6;">rtos</span> oo_py_dict <span style="color: #b5cea8;">2</span> <span style="color: #b5cea8;">4</span>))
-
- (<span style="color: #569cd6;">setq</span> oo_py_dict_d (<span style="color: #569cd6;">getreal</span> (<span style="color: #569cd6;">strcat</span> <span style="color: #ce9178;">"\n偏移距离:<"</span> oo_py_dict_s <span style="color: #ce9178;">">\n"</span>)))
- <span style="color: #6a9955;">;创建选择集oo_ss,设置图层过滤器()</span>
- <span style="color: #6a9955;">; (setq oo_ss (ssget (list (cons 8 layer-name))))</span>
-
- (<span style="color: #569cd6;">setq</span> oo_ss_layer_str (<span style="color: #569cd6;">cdr</span> (<span style="color: #569cd6;">assoc</span> <span style="color: #b5cea8;">8</span> (<span style="color: #569cd6;">entget</span> (<span style="color: #569cd6;">car</span> (<span style="color: #569cd6;">entsel</span> <span style="color: #ce9178;">"\n获取图型所在图层"</span>))))))
- (<span style="color: #569cd6;">setq</span> oo_ss (<span style="color: #569cd6;">ssget</span> (<span style="color: #569cd6;">list</span> (<span style="color: #569cd6;">cons</span> <span style="color: #b5cea8;">8</span> oo_ss_layer_str))))
- <span style="color: #6a9955;">;or 判断是否需要输入偏移距离,输入则切换,无输入则保持</span>
- <span style="color: #6a9955;">; (or</span>
- <span style="color: #6a9955;">; (oo_py_dict)</span>
- <span style="color: #6a9955;">; (setq oo_py_dict(getreal ))</span>
- <span style="color: #6a9955;">; )</span>
-
- (<span style="color: #569cd6;">if</span> (<span style="color: #569cd6;">and</span> (/= oo_py_dict_d <span style="color: #ce9178;">""</span>) (/= oo_py_dict_d <span style="color: #ce9178;">"0"</span>) (/= oo_py_dict_d <span style="color: #b5cea8;">0</span>) (/= oo_py_dict_d <span style="color: #569cd6;">nil</span>))
- (<span style="color: #569cd6;">setq</span> oo_py_dict oo_py_dict_d)
- )
-
- (<span style="color: #569cd6;">setq</span> ss_length (<span style="color: #569cd6;">sslength</span> oo_ss))
- (<span style="color: #569cd6;">setq</span> temp_i <span style="color: #b5cea8;">0</span>)
-
- <span style="color: #6a9955;">;偏移后置为当前图层</span>
- (<span style="color: #569cd6;">command</span> <span style="color: #ce9178;">"offset"</span> <span style="color: #ce9178;">"l"</span> <span style="color: #ce9178;">"c"</span> <span style="color: #ce9178;">""</span> <span style="color: #ce9178;">""</span>)
- <span style="color: #6a9955;">;将选择集遍历赋值给ss_i_ename (ename) 取出单个图元</span>
- (<span style="color: #569cd6;">repeat</span> ss_length
- (<span style="color: #569cd6;">setq</span> ss_i_ename (<span style="color: #569cd6;">ssname</span> oo_ss temp_i))
- <span style="color: #6a9955;">;对每个ename需要操作的内容,取出list,用于提取数据</span>
- (<span style="color: #569cd6;">setq</span> ename_list (<span style="color: #569cd6;">entget</span> ss_i_ename))
- (<span style="color: #569cd6;">setq</span> ename_type (<span style="color: #569cd6;">assoc</span> <span style="color: #b5cea8;">0</span> ename_list))
-
- <span style="color: #6a9955;">;如果是圆形(圆心y+半径)</span>
- (<span style="color: #569cd6;">if</span> (<span style="color: #569cd6;">equal</span> ename_type (<span style="color: #569cd6;">cons</span> <span style="color: #b5cea8;">0</span> <span style="color: #ce9178;">"CIRCLE"</span>))
- (<span style="color: #569cd6;">progn</span>
- (<span style="color: #569cd6;">if</span> (<span style="color: #569cd6;">equal</span> oo_py_fs_str <span style="color: #ce9178;">"n"</span>)
- (<span style="color: #569cd6;">setq</span> oo_py_fs_num (* <span style="color: #b5cea8;">-1</span> (<span style="color: #569cd6;">cdr</span> (<span style="color: #569cd6;">nth</span> <span style="color: #b5cea8;">10</span> ename_list)))))
-
- (<span style="color: #569cd6;">if</span> (<span style="color: #569cd6;">equal</span> oo_py_fs_str <span style="color: #ce9178;">"w"</span>)
- (<span style="color: #569cd6;">setq</span> oo_py_fs_num (<span style="color: #569cd6;">cdr</span> (<span style="color: #569cd6;">nth</span> <span style="color: #b5cea8;">10</span> ename_list))))
- (<span style="color: #569cd6;">command</span> <span style="color: #ce9178;">"offset"</span> oo_py_dict ss_i_ename (<span style="color: #569cd6;">list</span> (<span style="color: #569cd6;">car</span> (<span style="color: #569cd6;">cdr</span> (<span style="color: #569cd6;">nth</span> <span style="color: #b5cea8;">9</span> ename_list))) (+ oo_py_fs_num (+ (<span style="color: #569cd6;">cdr</span> (<span style="color: #569cd6;">nth</span> <span style="color: #b5cea8;">10</span> ename_list)) (<span style="color: #569cd6;">cadr</span> (<span style="color: #569cd6;">cdr</span> (<span style="color: #569cd6;">nth</span> <span style="color: #b5cea8;">9</span> ename_list)))))) <span style="color: #ce9178;">""</span>)
- )
- )
-
- <span style="color: #6a9955;">;如果是矩形(矩形中心点,y轴半高)</span>
- (<span style="color: #569cd6;">if</span> (<span style="color: #569cd6;">equal</span> ename_type (<span style="color: #569cd6;">cons</span> <span style="color: #b5cea8;">0</span> <span style="color: #ce9178;">"LWPOLYLINE"</span>))
- (<span style="color: #569cd6;">progn</span>
- <span style="color: #6a9955;">;对角点获取办法</span>
- (<span style="color: #569cd6;">setq</span> p3_nth (+ (/ (- (<span style="color: #569cd6;">length</span> ename_list) <span style="color: #b5cea8;">15</span>) <span style="color: #b5cea8;">2</span>) <span style="color: #b5cea8;">14</span>))
-
- <span style="color: #6a9955;">;p1起点</span>
- (<span style="color: #569cd6;">setq</span> p1 (<span style="color: #569cd6;">list</span> (<span style="color: #569cd6;">setq</span> p1x (<span style="color: #569cd6;">cadr</span> (<span style="color: #569cd6;">nth</span> <span style="color: #b5cea8;">14</span> ename_list))) (<span style="color: #569cd6;">setq</span> p1y (<span style="color: #569cd6;">caddr</span> (<span style="color: #569cd6;">nth</span> <span style="color: #b5cea8;">14</span> ename_list)))))
- (<span style="color: #569cd6;">setq</span> p3 (<span style="color: #569cd6;">list</span> (<span style="color: #569cd6;">setq</span> p3x (<span style="color: #569cd6;">cadr</span> (<span style="color: #569cd6;">nth</span> p3_nth ename_list))) (<span style="color: #569cd6;">setq</span> p3y (<span style="color: #569cd6;">caddr</span> (<span style="color: #569cd6;">nth</span> p3_nth ename_list)))))
-
- <span style="color: #6a9955;">;矩形中心点</span>
- <span style="color: #6a9955;">;矩形半高 (/ (- p1y p3y) 2)</span>
- (<span style="color: #569cd6;">if</span> (> p1y p3y)
- (<span style="color: #569cd6;">progn</span>
- (<span style="color: #569cd6;">if</span> (<span style="color: #569cd6;">equal</span> oo_py_fs_str <span style="color: #ce9178;">"n"</span>)
- (<span style="color: #569cd6;">setq</span> oo_py_fs_num (* <span style="color: #b5cea8;">-1</span> (/ (- p1y p3y) <span style="color: #b5cea8;">2</span>))))
-
- (<span style="color: #569cd6;">if</span> (<span style="color: #569cd6;">equal</span> oo_py_fs_str <span style="color: #ce9178;">"w"</span>)
- (<span style="color: #569cd6;">setq</span> oo_py_fs_num (/ (- p1y p3y) <span style="color: #b5cea8;">2</span>)))
-
- (<span style="color: #569cd6;">if</span> (< p1x p3x)
- (<span style="color: #569cd6;">command</span> <span style="color: #ce9178;">"offset"</span> oo_py_dict ss_i_ename (<span style="color: #569cd6;">list</span> (+ (/ (- p3x p1x) <span style="color: #b5cea8;">2</span>) p1x) (+ oo_py_fs_num p1y)) <span style="color: #ce9178;">""</span>)
- (<span style="color: #569cd6;">command</span> <span style="color: #ce9178;">"offset"</span> oo_py_dict ss_i_ename (<span style="color: #569cd6;">list</span> (+ (/ (- p1x p3x) <span style="color: #b5cea8;">2</span>) p3x) (+ oo_py_fs_num p1y)) <span style="color: #ce9178;">""</span>)))
-
- (<span style="color: #569cd6;">if</span> (> p3y p1y)
- (<span style="color: #569cd6;">progn</span>
- (<span style="color: #569cd6;">if</span> (<span style="color: #569cd6;">equal</span> oo_py_fs_str <span style="color: #ce9178;">"n"</span>)
- (<span style="color: #569cd6;">setq</span> oo_py_fs_num (* <span style="color: #b5cea8;">-1</span> (/ (- p3y p1y) <span style="color: #b5cea8;">2</span>))))
-
- (<span style="color: #569cd6;">if</span> (<span style="color: #569cd6;">equal</span> oo_py_fs_str <span style="color: #ce9178;">"w"</span>)
- (<span style="color: #569cd6;">setq</span> oo_py_fs_num (/ (- p3y p1y) <span style="color: #b5cea8;">2</span>)))
-
- (<span style="color: #569cd6;">if</span> (< p1x p3x)
- (<span style="color: #569cd6;">command</span> <span style="color: #ce9178;">"offset"</span> oo_py_dict ss_i_ename (<span style="color: #569cd6;">list</span> (+ (/ (- p3x p1x) <span style="color: #b5cea8;">2</span>) p1x) (+ oo_py_fs_num p3y)) <span style="color: #ce9178;">""</span>)
- (<span style="color: #569cd6;">command</span> <span style="color: #ce9178;">"offset"</span> oo_py_dict ss_i_ename (<span style="color: #569cd6;">list</span> (+ (/ (- p1x p3x) <span style="color: #b5cea8;">2</span>) p3x) (+ oo_py_fs_num p3y)) <span style="color: #ce9178;">""</span>))
- )
- )
- )
- )
- )
- <span style="color: #6a9955;">;矩形判断-结束</span>
- <span style="color: #6a9955;">;(subst (cons 8 (getvar "clayer")) (assoc 8 (entget (entlast))) (entget (entlast)))</span>
- (<span style="color: #569cd6;">setq</span> temp_i (+ <span style="color: #b5cea8;">1</span> temp_i))
- )
- )
-
-
-
- </div>
- </div>
写了个指定图层批量偏移到当前图层,但是只能偏移圆和4个点的矩形。图中这种圆角的图形就用不了, vla-offset可以不用取点 , 但是不知到怎么偏移到指定图层 ,很惆怅
;---------------------------------------------------------
vlisp好像也会被起点影响到..
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
x
|