Insert block to polyline

Insert block to polyline

C.Utzinger
Collaborator Collaborator
1,281 Views
3 Replies
Message 1 of 4

Insert block to polyline

C.Utzinger
Collaborator
Collaborator

Hi

 

I have this code

(defun c:<Verteillinie ( / en start ang1 ang2 ende)
           (setvar "plinetype" 2)
	   (princ "\nStartpunkt angeben: ")
	   (command "_pline" (while (/=(getvar "CMDACTIVE")0)(command pause (princ "\nNächsten Punkt angeben (am Ende Enter): "))))
  (if (and (setq en (entlast))
           (wcmatch (cdr (assoc 0 (entget en))) "LWPOLYLINE,LINE,ARC")
           (setq start (vlax-curve-getStartPoint en))
           (setq ang1 (angle (trans '(0 0 0) 0 1) (trans (vlax-curve-getFirstDeriv en (vlax-curve-getStartParam en)) 0 1)))
           (setq start (trans start 0 1))
           (setq ende (vlax-curve-getEndPoint en))
           (setq ende (trans ende 0 1))
           (setq ang2 (angle (trans (vlax-curve-getFirstDeriv en (vlax-curve-getEndParam en)) 0 1)(trans '(0 0 0) 0 1)))
           )
	   (command "_.insert" "spi-bew-pfeil" "_scale" 12.5 "_r" (angtos ang1) "_none" start
             "_.insert" "spi-bew-pfeil" "_scale" 12.5 "_r" (angtos ang2) "_none" ende))
           (prin1)
) ; end of defun

 

It works fine. But the arrows are not perfectly allined with the polyline.

 

Is something wrong in the code?

 

Thanks

0 Likes
Accepted solutions (1)
1,282 Views
3 Replies
Replies (3)
Message 2 of 4

ВeekeeCZ
Consultant
Consultant
Accepted solution

See the fixed code.

 

* The issue with precision was because (angtos) without any argument - it took a precision set in your drawing (_units command) which was not enough.

* The second issue was in the part where you drawing a polyline. That was messed up, it made each vertex twice!

 

 

Spoiler
(defun c:<Verteillinie ( / en start ang1 ang2 ende)
  (setvar "plinetype" 2)
  (princ "\nStartpunkt angeben: ")
  (command "_.pline")
  (while (> (getvar "CMDACTIVE") 0)
    (command pause)
    (princ "\nNächsten Punkt angeben (am Ende Enter): "))
  
  (if (and (setq en (entlast))
	   (wcmatch (cdr (assoc 0 (entget en))) "LWPOLYLINE,LINE,ARC")
	   (setq start (vlax-curve-getStartPoint en))
	   (setq ang1 (angle (trans '(0 0 0) 0 1) (trans (vlax-curve-getFirstDeriv en (vlax-curve-getStartParam en)) 0 1)))
	   (setq start (trans start 0 1))
	   (setq ende (vlax-curve-getEndPoint en))
	   (setq ende (trans ende 0 1))
	   (setq ang2 (angle (trans (vlax-curve-getFirstDeriv en (vlax-curve-getEndParam en)) 0 1)(trans '(0 0 0) 0 1)))
	   )
    (command "_.insert" "spi-bew-pfeil" "_scale" 12.5 "_r" (angtos ang1 (getvar 'aunits) 10) "_none" start
	     "_.insert" "spi-bew-pfeil" "_scale" 12.5 "_r" (angtos ang2 (getvar 'aunits) 10) "_none" ende))
  (prin1)
  ) ; end of defun
Message 3 of 4

C.Utzinger
Collaborator
Collaborator

Thank you!

0 Likes
Message 4 of 4

Ranjit_Singh
Advisor
Advisor

try replacing (angtos ang1) and (angtos ang2) to (angtos ang1 0 14) and (angtos ang2 0 14)

0 Likes