Lee Mac 发表于 2022-7-6 11:23:57

优秀点艾伦-代码更新。
 
谢谢

alanjt 发表于 2022-7-6 11:25:09

不客气。

Lee Mac 发表于 2022-7-6 11:29:49

更新为正确的UCS

alanjt 发表于 2022-7-6 11:31:48

你是否对UCS进行了另一次更新?

Lee Mac 发表于 2022-7-6 11:36:32

 
是,允许正常值的变化。

alanjt 发表于 2022-7-6 11:39:29

啊,好的。
......

SEANT 发表于 2022-7-6 11:41:28

在处理奇数方向的插入时,技术组合是否更可靠?见所附示例。
 
请原谅我之前发布的混合和匹配代码。
 
(defun c:AtInsert2 ( / obj )
(if
   (setq obj
   (SelectifFoo
       (lambda ( x )
         (if
         (vlax-property-available-p
             (setq x (vlax-ename->vla-object x)) 'InsertionPoint
         )
         x
         )
       )
       "\nSelect Object: "
   )
   )
   (command "_.line" "_non"(trans (vlax-get obj 'InsertionPoint) 0 1))
)
)
(defun SelectifFoo ( foo str / sel x )
(while
   (progn
   (setq sel (entsel str))
   
   (cond
       (
         (vl-consp sel)

         (if (not (setq x (foo (car sel))))
         (princ "\n** Invalid Object Selected **")
         )
       )
   )
   )
)
x
)
插入。图纸

alanjt 发表于 2022-7-6 11:45:06

让我们把它混合得更多。。。
 
(defun c:AtInsert3 (/ obj)
(if
   (setq obj
          (SelectifFoo
            (lambda (x)
            (if
                (vlax-property-available-p
                  (setq x (vlax-ename->vla-object x))
                  'InsertionPoint
                )
               x
            )
            )
            "\nSelect Object: "
          )
   )
    ;; AJT begin edit
    ((lambda (ins)
       (if (eq 1 (logand 1 (getvar 'cmdactive)))
         ins
         (command "_.line" "_non" ins)
       )
   )
      (trans (vlax-get obj 'InsertionPoint) 0 1)
    )
    ;; AJT end edit
)
)
(defun SelectifFoo (foo str / sel x)
(while
   (progn
   (setq sel (entsel str))

   (cond
       (
      (vl-consp sel)

      (if (not (setq x (foo (car sel))))
          (princ "\n** Invalid Object Selected **")
      )
       )
   )
   )
)
x
)

stevesfr 发表于 2022-7-6 11:46:35

 
这是迄今为止最好的代码!!!我们就快到了!!当选取一个属性来开始这条线时,它实际上是从块的插入点开始的,现在,如果第二个点或线的端点也可以从另一个属性中选取(而不是输入“AtInsert3”),我们将得到我想要的解决方案!然后继续行到下一个属性等。。。。。
太棒了,艾伦!!!
S

alanjt 发表于 2022-7-6 11:49:59

(defun c:AtInsert3 (/ obj)
(if
   (setq obj
          (SelectifFoo
            (lambda (x)
            (if
                (vlax-property-available-p
                  (setq x (vlax-ename->vla-object x))
                  'InsertionPoint
                )
               x
            )
            )
            "\nSelect Object: "
          )
   )
    ;; AJT begin edit
    ((lambda (ins)
       (if (eq 1 (logand 1 (getvar 'cmdactive)))
         ins
         (command "_.line" "_non" ins "_non" (c:ATInsert3))
       )
   )
      (trans (vlax-get obj 'InsertionPoint) 0 1)
    )
    ;; AJT end edit
)
)
(defun SelectifFoo (foo str / sel x)
(while
   (progn
   (setq sel (entsel str))

   (cond
       (
      (vl-consp sel)

      (if (not (setq x (foo (car sel))))
          (princ "\n** Invalid Object Selected **")
      )
       )
   )
   )
)
x
)
 
当然,如果这就是你想要的,这可以简单得多。
页: 1 [2]
查看完整版本: 插入块时开始行