Jump to content

Recommended Posts

Posted (edited)

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
Posted

I sent you a message a couple of days ago as I misunderstood your prior request. I posted an answer for another request and it will be easy to add the offset, angle and Z when inserting.

 

The issue is to do with the xls need to make a csv then its easy. The problem is in the x y z using "," as delimeter.

 

Watch this space.

Posted (edited)

This is for you to try it may not be quite right so let me know, it uses your other posted dwg and xls that have a lot more details. Back in March 2020.

 

I have attached the csv file I made from your prior xls make sure you run in a dwg with the blocks existing. 

 

Not sure what the angle refers to in the excel.

 

Change the filename I have used for testing will change to a explorer option once know it is working. D:\\acadtemp\\tram posts.csv

 

; Take a csv file of block details and make in Cad
; By Alan H May 2020 info@alanh.com.au

(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

Edited by BIGAL

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...