Jump to content

Recommended Posts

Posted

Hi all.

 

I've tried pulling together an autolisp for a repetitive procedure that is about to bug our office but I just don't have the know how at this stage to make it work.

 

We basically need to use the "measure" command to insert a block on (many) multiple polylines at regular 20m intervals.

 

Can someone advise or give sample code that would do this?

 

Basically select the measure command, allow me to select the polyline (or select multiple polylines, that would be even better!), select the Block option, enter block name (call it Block1 for now), confirm Y for alignment with the polyline, and then auto specify 20m intervals.

 

Any / all help appreciated!

  • Replies 25
  • Created
  • Last Reply

Top Posters In This Topic

  • ajazraj

    9

  • alanjt

    6

  • Tharwat

    3

  • kylesom

    2

Top Posters In This Topic

Posted

Check this out Buddy .:)

 

(defun c:TesT (/ blk ss l name)
 ; TharwaT 04. 04. 2011
 (if
   (and (setq blk (entsel "\n Select Block :"))
        (setq ss (ssget "_:L" '((0 . "LINE,SPLINE,LWPOLYLINE,POLYLINE"))))
        (setq l (getdist "\n Distance between Blocks :"))
   )
    (progn
      (setq name (cdr (assoc 2 (entget (car blk)))))
      ((lambda (i / ss1)
         (while
           (setq ss1 (ssname ss (setq i (1+ i))))
            (command "_.measure" ss1 "Block" name "_Y" l)
         )
       )
        -1
      )
    )
    (princ)
 )
 (princ)
)

 

TharwaT

Posted
Check this out Buddy .:)

 

(defun c:TesT (/ blk ss l name)
; TharwaT 04. 04. 2011
(if
(and (setq blk (entsel "\n Select Block :"))
(setq ss (ssget "_:L" '((0 . "LINE,SPLINE,LWPOLYLINE,POLYLINE"))))
(setq l (getdist "\n Distance between Blocks :"))
)
(progn
(setq name (cdr (assoc 2 (entget (car blk)))))
((lambda (i / ss1)
(while
(setq ss1 (ssname ss (setq i (1+ i))))
(command "_.measure" ss1 "Block" name "_Y" l)
)
)
-1
)
)
(princ)
)
(princ)
)

 

TharwaT

 

This is great ! How can I make modification to change the scale of selected block as it is being inserted ?

thanks, Steveo

Posted
This is great ! How can I make modification to change the scale of selected block as it is being inserted ?

thanks, Steveo

 

Thank you .

 

I guess you can not scale the block that going to be distributed along the selected line because the command measure would

insert the block by its name and not as selected object .

 

May be someone else could bring something against this truth . :)

 

TharwaT

Posted

You would need to roll your own with vlax-curve-getPointAtDist (see my CopyAlongCurve.LSP) or store the last entity (entlast) before you measure each object, then, after curve has been measured, use entnext to select each newly created object (block) and rescale, based on scale properties of originally selected block.

Posted

Steve

Try this slightly edited code

(defun c:TesT2 (/ blk ss l name)
; TharwaT 04. 04. 2011
(if
(and (setq blk (entsel "\n Select Block :"))
(setq ss (ssget "_:L" '((0 . "LINE,SPLINE,LWPOLYLINE,POLYLINE"))))
(setq l (getdist "\n Distance between Blocks :"))
(setq scl (getdist "\n Enter a scale :"))   
)
(progn
(setq name (cdr (assoc 2 (entget (car blk)))))
((lambda (i / ss1)
(while
(setq ss1 (ssname ss (setq i (1+ i))))
(setq marker(entlast))
(command "_.measure" ss1 "Block" name "_Y" l)
(while (setq en (entnext marker))
 (setq elist (entget en)
pt (cdr (assoc 10 elist)))
 (command "_scale" en "" "_non" pt scl)
 (princ (cdr (assoc 2 elist)))
(entupd en)
(setq marker en)
)
)
)
-1
)
)
(princ)
)
(princ)
)

 

~'J'~

Posted
Steve

Try this slightly edited code

(defun c:TesT2 (/ blk ss l name)
; TharwaT 04. 04. 2011
(if
(and (setq blk (entsel "\n Select Block :"))
(setq ss (ssget "_:L" '((0 . "LINE,SPLINE,LWPOLYLINE,POLYLINE"))))
(setq l (getdist "\n Distance between Blocks :"))
(setq scl (getdist "\n Enter a scale :")) 
)
(progn
(setq name (cdr (assoc 2 (entget (car blk)))))
((lambda (i / ss1)
(while
(setq ss1 (ssname ss (setq i (1+ i))))
(setq marker(entlast))
(command "_.measure" ss1 "Block" name "_Y" l)
(while (setq en (entnext marker))
(setq elist (entget en)
pt (cdr (assoc 10 elist)))
(command "_scale" en "" "_non" pt scl)
(princ (cdr (assoc 2 elist)))
(entupd en)
(setq marker en)
)
)
)
-1
)
)
(princ)
)
(princ)
)

 

~'J'~

 

fixo !!! you did it !! thanks, Steve

Posted

Steve,

You're welcome

But thanks to Tharwat :)

Cheers, friend

 

Oleg

  • 2 years later...
Posted

how can i use the above lisp for varrying spacing between to blocks...

Posted
how can i use the above lisp for varrying spacing between to blocks...
The MEASURE command does equal spacing. Did you want UNequal spacing? If so, MEASURE is not the way to go. How much varying do you need? It would be better to show a clear example by uploading a drawing with a pline with several blocks correctly placed along it.
Posted
The MEASURE command does equal spacing. Did you want UNequal spacing? If so, MEASURE is not the way to go. How much varying do you need? It would be better to show a clear example by uploading a drawing with a pline with several blocks correctly placed along it.

 

sorry for the late reply....

 

i have attached a sample dwg. herewith.., now the thing is... i have a horizontal alignment of a metro rail... and i need to place a piers along it , which has non-uniform spacing. suppose if i have data in excel with pier spacing and numbers, can i link excel sheet with any lisp so that it can then be updated afterwards if needed.

trial.dwg

Posted
Steve

Try this slightly edited code

(defun c:TesT2 (/ blk ss l name)
; TharwaT 04. 04. 2011
(if
(and (setq blk (entsel "\n Select Block :"))
(setq ss (ssget "_:L" '((0 . "LINE,SPLINE,LWPOLYLINE,POLYLINE"))))
(setq l (getdist "\n Distance between Blocks :"))
(setq scl (getdist "\n Enter a scale :"))   
)
(progn
(setq name (cdr (assoc 2 (entget (car blk)))))
((lambda (i / ss1)
(while
(setq ss1 (ssname ss (setq i (1+ i))))
(setq marker(entlast))
(command "_.measure" ss1 "Block" name "_Y" l)
(while (setq en (entnext marker))
 (setq elist (entget en)
pt (cdr (assoc 10 elist)))
 (command "_scale" en "" "_non" pt scl)
 (princ (cdr (assoc 2 elist)))
(entupd en)
(setq marker en)
)
)
)
-1
)
)
(princ)
)
(princ)
)

 

~'J'~

 

 

fixo, can u tell me how can i use the above lisp for unequal spacing between blocks?

Posted
fixo, can u tell me how can i use the above lisp for unequal spacing between blocks?
ajazraj, like I tried to explain earlier, this uses the MEASURE command, which uses equal spacing, thus this sort of code will not work for your case. I did not open your DWG because I'm limited to 2012 and below, but your idea of using a spreadsheet to place items along a horizontal line should be doable, if one of the experts here is game. What kind of updating were you hoping for? It might be simpler to just erase and redo the entire thing if there are changes.
Posted
ajazraj, like I tried to explain earlier, this uses the MEASURE command, which uses equal spacing, thus this sort of code will not work for your case. I did not open your DWG because I'm limited to 2012 and below, but your idea of using a spreadsheet to place items along a horizontal line should be doable, if one of the experts here is game. What kind of updating were you hoping for? It might be simpler to just erase and redo the entire thing if there are changes.

 

neophoible.... yes, i understand that measure command can not be used.

i am attaching dwg. saved in 2007, look at it if possible.

 

LISP suggested by alanjt is quite useful, but still i want to give inputs of spacing through excel.

 

neophoible.... i dnt want to update dwg. as i change the excel, i know that i have to run the lisp again. What i really needed is to give input of spacing through excel.

 

Thank You

trial_2007.dwg

Posted
Thank You, alanjt ... it is quite useful, but still it is not what i exactly want.

 

The Dynamic option doesn't do what you want?

Posted
The Dynamic option doesn't do what you want?

 

I dont have much idea about dynamic blocks.

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