Jump to content

explanation of the angle when inserting a block


Nowak

Recommended Posts

Hello,

I insert 3D blocks thanks to one of Patrick's lisp, which is the IXL lisp, the blocks fit very well, but there is just one problem, it's that I don't know what the angle is , so that the block is perpendicular to the polyline. So if anyone can help me clear this up, thank you in advance.

 

 

Edited by Nowak
Link to comment
Share on other sites

I thought I posted this already have you double posted ? It has a hard coded test csv file you will need to change.

 

; Take a csv file of text details and make in Cad
; By Alan H May 2018

(defun c:Tram-posts ( / fname str  newlst pt angl isblk oldsnap oldaunits )

(defun alg-ang (objpl pnt)
  (angle '(0. 0. 0.)
     (vlax-curve-getfirstderiv
       objpl
       (vlax-curve-getparamatpoint
         objpl
         pnt
       )
     )
  )
)


; thanks to Lee-mac for this defun 
; www.lee-mac.com
; 44 is comma
(defun _csv->lst ( str / pos )
	(if (setq pos (vl-string-position 44 str))
		(cons (substr str 1 pos) (_csv->lst (substr str (+ pos 2))))
		(list str)
    )
)

(defun dtr (a)
(* pi (/ a 180.0))
)

(defun chkblk ( bname )
(setq isblk (tblsearch "BLOCK" bname))
(if (/= isblk nil)
(princ)
(alert (strcat "Block " bname " is missing"))
)
)

; program starts here hardcoded for testing
(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)
(setq oldaunits (getvar 'aunits))
(setvar 'aunits 3)

(setq obj (vlax-ename->vla-object (car (entsel "Pick pline "))))

(setq newlst '())
(setq fname (open "D:\\acadtemp\\tram posts.csv" "r"))
(setq newline (read-line fname))
(while (setq newline (read-line fname))
	(setq newlst (cons ( _csv->lst newline) newlst))
	
)
(close fname)
(princ)

(foreach lst newlst
(setq blk (nth 0 lst))
(chkblk blk)
(if (and (/= isblk nil)(/= (substr blk 1 1) ""))
(progn
(setq dist (atof (nth 1 lst))
off (atof (nth 2 lst))
Z (atof (nth 3 lst))
ang (atof(nth 4 lst))
)
(setq pt (VLAX-CURVE-GETPOINTATDIST obj dist))
(setq  angl (alg-ang obj pt))
(setq pt (polar pt angl off))
(setq pt (list (car pt)(cadr pt) z))
(command "-insert" blk pt 1 1 angl)
)
)
)

(setvar 'osmode oldsnap)
(setvar 'aunits oldaunits)
(princ)

)

image.png.4e99c980a9ba0b85ed896a2686fad05c.png

Tram posts.csv

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...