1

我目前正在尝试在沿另一条折线运行的两个块(first_block,second_block)之间运行一条折线,在操作结束时调用一个插入函数,该函数使用开始和结束块的详细信息填充注释块(cable_name_tag) .

该多段线将横切其他块,并且通常需要与底层多段线(cable_ducting)平行运行,因此用户需要选择多段线的适当部分来放置注释,因为空间有时是有限的。

我已经注意到,如果我注释掉 second_block 并提供一个硬编码值,那么 ssget 函数可以正常工作,所以我有理由确定问题出在该代码中 first_block 和 second_block 的语法或处理上。

(defun c:cable ()
  (vl-load-com)
  (setvar "clayer" "cable layer")
  (setvar "celtype" "bylayer")
  (setvar "osmode" 515)
  (command "_.pline"
           (getpoint))
  (while (> (getvar ' cmdactive) 0)
    (command pause)
    (princ "\npress enter to finish:"))
  (setq elst
        (entsel "\nselect cable segment: "))
  (setq ename
        (car elst))
  (setq pt
        (cadr elst))
  (setq annopt pt)
  (setq pt
        (vlax-curve-getclosestpointto ename pt))
  (setq param
        (vlax-curve-getparamatpoint ename pt))
  (setq preparam
        (fix param))
  (setq postparam
        (1+ preparam))
  (list (setq pt1
              (vlax-curve-getpointatparam ename preparam))
        (setq pt2
              (vlax-curve-getpointatparam ename postparam)))
  (setq cable
        (entlast))
  (setq cable_start
        (vlax-curve-getstartparam cable))
  (setq cable_start_point
        (vlax-curve-getstartpoint cable))
  (setq cable_end_point
        (vlax-curve-getendpoint cable))
  (setq cable_end
        (angtos (angle '(0 0)
                       (vlax-curve-getfirstderiv cable 0.0))))
  (setq first_block
        (ssget "_c" cable_start_point cable_end_point
               (list (cons 0 "insert")
                     (cons 2 "first_block"))))
  (setq second_block
        (ssget "_c" cable_start_point cable_end_point
               (list (cons 0 "insert")
                     (cons 2 "second_block"))))
  (setq end_cable
        (ssname second_block 0))
  (setq start_cable
        (ssname first_block 0))
  (setq $end_cable
        (vla-get-textstring
         (cadr (vlax-safearray->list
                (variant-value
                 (vla-getattributes
                  (vlax-ename->vla-object end_cable)))))))
  (setq $start_cable
        (vla-get-textstring
         (cadr (vlax-safearray->list
                (variant-value
                 (vla-getattributes
                  (vlax-ename->vla-object start_cable)))))))
  (setq cable_name
        (vlax-curve-getendparam cable))
  (command ; insert cable param
           "-insert"
           "cable_name_tag"
           annopt
           "1"
           "1"
           cable_angle
           cable_name
           $start_cable
           $end_cable
           "144"
           cable_length))

我被困在这个角落里,如果有人能提供任何帮助、建议或指示,我将不胜感激。

谢谢大家的时间。

4

1 回答 1

1

为什么不直接使用(entlast)来获取刚刚创建的实体?

于 2012-09-21T01:35:43.980 回答