careca 发表于 2022-7-6 07:34:28

帮助Lisp执行多个

大家好,
 
这可能是我的第一个lisp脚本之一。。。。我有点困了。
 
我想要创建的是一个应用程序,它可以自动创建边界、进行内部偏移、对创建的偏移进行圆角,最后删除原始边界。所有这些都应该在拾取点时工作。
 
当我发现我必须首先分解偏移元素,使所有线段成为多段线以进行适当的圆角(否则圆弧等不起作用),这就是我陷入困境的地方。
 
如果有人能给我任何有用的提示,我们将不胜感激。
 
thnx。
卡雷卡
 
以下是我取得的成绩代码:
 

(defun c:xfillet (/ pt)

   ; while picking point -----------------------------
   (while (setq pt (getpoint "\nPick internal point: "))

   (command "_.-boundary" "_a" "_i" "_n" "" "" "_non" pt "")

       ; store original boundary object
       (setq original_boundary (entlast))

       ; make offset
       (command "_.offset" 10 (entlast) "_non" pt "")
      
       ; explode offset
       (command "_.explode" (entlast))

       ; load selection set
       (setq ss (ssget "_P"))
      
       ;counter
       (setq x 1)
      
       ;loop for all elements -------------------
       (repeat (sslength ss)
               
         (setq pa (getvar "peditaccept"))
         
         ; convert all segments into polylines -> so fillet works on all elements
         (setvar "peditaccept" 1)
         (command "pedit" ss nil)
         (setvar "peditaccept" pa)
         
         ; copy element onto layer 0
         (command "_.chprop" (entlast) "" "LA" "0" "")
         
         ; change color of element (included just for texting)
         (command "change" (entlast) "" "prop" "color" x "")

         ; ++++++++++++++++++++++++++++++++
         ; ++++++++++++++++++++++++++++++++
         
         ; what I want to accomplish
         
         ; store first element
         if x = 1 then
         store element in el1
         
         ; loop though elements, make fillets bit by bit
         if x >= 2
         make fillet with el1
         store new element as el1
         

         ; ++++++++++++++++++++++++++++++++
         ; ++++++++++++++++++++++++++++++++
         
         (setvar "peditaccept" pa)
         
         ; counter up
         (setq x (+ x 1))
      
      ; _end repeat
      )
      
      ; delete original boundary
      (command "_.erase" original_boundary "")


   ) ; end while
   
   ;(princ)
) ; end

Dadgad 发表于 2022-7-6 07:38:25

您好careca,欢迎来到论坛。
 
如果在命令行中将Peditacept系统变量设置为1,则
通过使用fillet命令行提示中的“多段线”选项,可以对偏移图元进行圆角。
我希望这对你有帮助。

careca 发表于 2022-7-6 07:41:07

 
嗨,Dadgad,
谢谢你的回复。
 
我确实试过这个,但似乎不起作用。
当试图通过多段线一次完成所有操作时,将省去弧段。
 
这就是为什么我认为我循环了元素的选择集。。。
 
马丁

Dadgad 发表于 2022-7-6 07:44:52

可以使用“多段线”命令创建圆弧。
指定起点,然后A>,以这种方式创建的任何弧都将是多段线。

careca 发表于 2022-7-6 07:48:29

 
好的,简而言之,以下是我想要实现的目标:
 

 
基本上是一个连续的点击操作,将我从第1步带到第6步。
但是,在第5步和第6步之间,需要分解偏移多段线以处理所有圆角,否则(原始)圆弧元素接触的边不起作用。
 
careca公司

Dadgad 发表于 2022-7-6 07:51:46

我明白你的意思了,我很惊讶当边界命令创建闭合多段线时,
已使用多段线选项进行偏移,尽管是闭合多段线,仍会产生以下消息。。。。。另一条关于一条直线发散(折线弧)的信息不断出现。

Lee Mac 发表于 2022-7-6 07:55:30

尝试一下:
 
(defun c:xf ( / *error* cm e0 e1 e2 e3 el p1 pe )

   (defun *error* ( msg )
       (if (= 'int (type cm))
         (setvar 'cmdecho cm)
       )
       (if (= 'int (type pe))
         (setvar 'peditaccept pe)
       )
       (if (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*"))
         (princ (strcat "\nError: " msg))
       )
       (princ)
   )
   
   (setq cm (getvar 'cmdecho)
         pe (getvar 'peditaccept)
   )
   (setvar 'cmdecho 0)
   (setvar 'peditaccept 1)
   (while (setq p1 (getpoint "\nPick Internal Point <Exit>: "))
       (setq e0 (entlast)
             el nil
       )
       (command "_.-boundary" "_A" "_I" "_N" "" "_O" "_P" "" "_non" p1 "")
       (setq e1 (entlast))
       (if (not (eq e0 e1))
         (progn
               (command "_.offset" 10.0 e1 "_non" p1 "")
               (setq e2 (entlast))
               (if (not (eq e1 e2))
                   (progn
                     (command "_.chprop" e2 "" "_LA" "0" "_C" 1 "")
                     (command "_.explode" e2)
                     (setq e3 e2)
                     (while (setq e3 (entnext e3))
                           (setq el (cons e3 el))
                     )
                     (mapcar
                        '(lambda ( a b ) (setvar 'filletrad 10.0) (command "_.fillet" a b))
                           (cons (last el) el)
                           el
                     )
                     (command "_.pedit" "_M")
                     (while (setq e2 (entnext e2))
                           (command e2)
                     )
                     (command "" "_J" "" "")
                   )
                   (alert "Unable to perform offset.")
               )
               (entdel e1)
         )
         (alert "Unable to detect boundary.")
       )
   )
   (setvar 'peditaccept pe)
   (setvar 'cmdecho cm)
   (princ)
)

marko_ribar 发表于 2022-7-6 07:59:26

李好极了。。。仅对代码进行了轻微修改(突出显示):
 

(defun c:xf ( / *error* cm e0 e1 e2 e3 el p1 pe ) (vl-load-com)

   (defun *error* ( msg )
       (if (= 'int (type cm))
         (setvar 'cmdecho cm)
       )
       (if (= 'int (type pe))
         (setvar 'peditaccept pe)
       )
       (if (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*"))
         (princ (strcat "\nError: " msg))
       )
       (princ)
   )
   
   (setq cm (getvar 'cmdecho)
         pe (getvar 'peditaccept)
   )
   (setvar 'cmdecho 0)
   (setvar 'peditaccept 1)
   (while (setq p1 (getpoint "\nPick Internal Point <Exit>: "))
       (setq e0 (entlast)
             el nil
       )
       (command "_.-boundary" "_A" "_I" "_N" "" "_O" "_P" "" "_non" p1 "")
       (setq e1 (entlast))
       (if (not (eq e0 e1))
         (progn
               (command "_.offset" 10.0 e1 "_non" p1 "")
               (setq e2 (entlast))
               (if (not (eq e1 e2))
                   (progn
                     (command "_.chprop" e2 "" "_LA" "0" "_C" 1 "")
                     (command "_.explode" e2)
                     (setq e3 e2)
                     (while (setq e3 (entnext e3))
                           (setq el (cons (vlax-curve-getpointatparam e3 (+ (vlax-curve-getstartparam e3) (/ (- (vlax-curve-getendparam e3) (vlax-curve-getstartparam e3)) 2.0))) el))
                     )
                     (mapcar
                        '(lambda ( a b ) (setvar 'filletrad 10.0) (command "_.fillet" a b))
                           (cons (last el) el)
                           el
                     )
                     (command "_.pedit" "_M")
                     (while (setq e2 (entnext e2))
                           (command e2)
                     )
                     (command "" "_J" "" "")
                   )
                   (alert "Unable to perform offset.")
               )
               (entdel e1)
         )
         (alert "Unable to detect boundary.")
       )
   )
   (setvar 'peditaccept pe)
   (setvar 'cmdecho cm)
   (princ)
)

 
M、 R。

Lee Mac 发表于 2022-7-6 08:01:26

 
原来的不适合你吗?

marko_ribar 发表于 2022-7-6 08:03:28

我试着复制jpg中发布的case OP,用你们的原稿,它错误地将最后一行用圆弧圆角,但只在左边部分——一个拾取边界;正确的一个,它做得正确。。。我想它有一些与圆角-它不知道如何连接实体(直线圆角与弧延伸,使几乎整个圆),当他们提供,而不是像我的修改中点。。。
页: [1] 2
查看完整版本: 帮助Lisp执行多个