Inserting blocks based on distance from excel file along a curved polyline

Inserting blocks based on distance from excel file along a curved polyline

Anonymous
Not applicable
1,210 Views
4 Replies
Message 1 of 5

Inserting blocks based on distance from excel file along a curved polyline

Anonymous
Not applicable

Hello!

I'm new to LISP, but I have a tough job and thoght that it can help. 

I have to put 5000 blocks along curved polyline with distance in excel file. I did it manualy at first, with arraypaths. I'd made path array with two items set on lenght, copied it many times in one place and then change properitys of lenght of each one. After that i exploded path array and got block at lenght I wanted. It was taking hours. 

I thought about LISP that make array paths with different lenght and two items, or just insert blocks at distance from xlsx file. Is it possible? I would be grateful for help.

 

Maciej

0 Likes
Accepted solutions (1)
1,211 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable

So I found this post

http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-create-arraypath-from-a-selec...

and it works quite well, but now I need to put distances automatically.

 

This LISP

https://sites.google.com/site/cadlispandtips/autocad-lisp/import-points

imports point values.

 

Is there a way to mix two LISPs together to make it work?

 

 

Maciej

0 Likes
Message 3 of 5

CADaSchtroumpf
Advisor
Advisor

See this if can help you

Message 4 of 5

ВeekeeCZ
Consultant
Consultant
Accepted solution

Good you're tried find solution on your own.

 

Here is what I found HERE - see spoiler

 

Spoiler
(defun C:test(/ ang cumm_dist dis dist_list leng obj pt)
  (vl-load-com)
  ;; build master list of the distances, starting from 0.0 - important!
  (setq dist_list '(0.0 1000.0 2000.0 3000.0 4000.0 5000.0))
  (setq cumm_dist (apply '+ dist_list))
  
  
  (setq dis 0.0)
  (setq obj (vlax-ename->vla-object (car (entsel "\n >> Select profile >>"))))
  (setq leng (vlax-curve-getdistatpoint obj (vlax-curve-getendpoint obj)))
  ;; check if pline length is not less than the cumulative distance
  (if (< leng cumm_dist)
    (progn
      (alert "Pline length is less then summary distance")
      (princ)
      )
    
    (while (< dis cumm_dist)
      (setq dis (+ dis (car dist_list)))
      (setq pt (vlax-curve-getpointatdist obj dis))
      ;;;***
      ;;to insert block named "tick":
      ;; get angle:
      (setq ang (angle '(0 0 0)
		       (vlax-curve-getfirstderiv obj
			 (vlax-curve-getparamatpoint obj pt))))
      ;;insert block:
      (vlax-invoke (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))
	'InsertBlock pt "tick" 1 1 1 ang);***
      
      ;;or draw point:
;;;      (vlax-invoke (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))
;;;	'AddPoint pt)
      (setq dist_list (cdr dist_list))
      )
    )
  (princ)
  )

Only think you need to do is adjust distance in EXCEL to given format - as distances between items, space delimited.

Then find and replace these test numbers. Keep parenthesis around. And adjust block name!

 

0.0 1000.0 2000.0 3000.0 4000.0 5000.0

 

 Thanks to @Hallex, the author.

Message 5 of 5

Anonymous
Not applicable

Thank you very much, it worked well.

0 Likes