LISP ROUTINE TO ADD BLOCK AT END OF A POLYLINE

LISP ROUTINE TO ADD BLOCK AT END OF A POLYLINE

Ajohnson0
Contributor Contributor
4,113 Views
29 Replies
Message 1 of 30

LISP ROUTINE TO ADD BLOCK AT END OF A POLYLINE

Ajohnson0
Contributor
Contributor

I am need to create a polyline that is the length of 52" and automatically inserts a block at the end of it. Is this possible?

 

0 Likes
Accepted solutions (1)
4,114 Views
29 Replies
Replies (29)
Message 21 of 30

Ajohnson0
Contributor
Contributor

Thanks for the reply? essentially all I want to do is have the CL block move and rotate with the p-line. Also delete with the p-line. I honestly don't have any lisp routine writing experience. I was wondering if you could modify the existing lisp routine you wrote for me to include this...I really appreciate your help

0 Likes
Message 22 of 30

Kent1Cooper
Consultant
Consultant

@Ajohnson0 wrote:

.... essentially all I want to do is have the CL block move and rotate with the p-line. Also delete with the p-line. ....


 

So clarify something for me....  The routine currently puts the Block in at zero rotation, regardless of the direction the Polyline runs, as in the left  side here:

ColLock.PNG

If that's what you need, then:
A)  If put into Blocks, each one would need its own name, so some suffix numbering or something would need to be built into the code.

B)  Your request to "have the CL block move and rotate  with the p-line" doesn't seem to fit.

 

If you want the "move and rotate with " part, as in the right  side of the image, and if the Polyline is always the same length and width, and the parts are always on their same Layers, you don't need a routine -- all you need is to simply define the combination as a Block, and Insert it wherever you want, giving it the appropriate rotation at each Insertion.  Presumably it would be defined oriented as in the lower right in the image, and the insertion base point would be at the left end of the Polyline, so that in dragging for rotation, it will always "aim" in the direction of the cursor rubber-band from the insertion point, in the same was as the determination of the direction in the routine.

Kent Cooper, AIA
0 Likes
Message 23 of 30

Ajohnson0
Contributor
Contributor

The routine on the right would be fine...I don't need the Column Lock to stay at 0

0 Likes
Message 24 of 30

Ajohnson0
Contributor
Contributor

@Kent1Cooper were you able to figure this out?

0 Likes
Message 25 of 30

Kent1Cooper
Consultant
Consultant

@Ajohnson0 wrote:

@Kent1Cooper were you able to figure this out?


If as you say in Message 23, the right image in Message 22 is okay, then see the last paragraph in Message 22 again:

 

"all you need is to simply define the combination as a Block"

Kent Cooper, AIA
0 Likes
Message 26 of 30

Ajohnson0
Contributor
Contributor

Alrighty, I am not sure how to do that as I am a newb to lisp routines. Nonetheless, I appreciate how much you have helped me. I'll just roll with the routine the way it is. Thanks again

0 Likes
Message 27 of 30

Kent1Cooper
Consultant
Consultant

@Ajohnson0 wrote:

Alrighty, I am not sure how to do that as I am a newb to lisp routines. Nonetheless, I appreciate how much you have helped me. I'll just roll with the routine the way it is. Thanks again


 

My point was that you don't need a routine at all, just a Block definition and the INSERT command.

Kent Cooper, AIA
0 Likes
Message 28 of 30

Ajohnson0
Contributor
Contributor

I am lost/confused. I'll just keep using it as is, I don't want to waste anymore of your time

0 Likes
Message 29 of 30

Ajohnson0
Contributor
Contributor

@Kent1Cooper , I have to say thanks again! as this has been working wonderfully. I was wondering if I could get a small change done. I would like to have the snaps turn off when the command is started and then turned back on after exited, is this possible?

0 Likes
Message 30 of 30

Kent1Cooper
Consultant
Consultant

@Ajohnson0 wrote:

.... snaps turn off when the command is started and then turned back on after exited....


In simplest terms:

 

(defun C:WHATEVER (/ osm pt1 pt2)
  (setq osm (getvar 'osmode)); save current Osnap mode(s)
  (setvar 'osmode 0); turn of running Osnap
  (command
    "_.pline" (setq pt1 (getpoint "\nStart of Pline: "))
    "_width" 3 3 (setq pt2 (getpoint pt1 "\nDirection: "))
    "_u" ; back off that segment
    (polar pt1 (angle pt1 pt2) 52) "" ; new end in that direction at required distance
    "_.chprop" "_last" "" "_layer" "Column_lock" ""
    "_.insert" "CL" "@" "" "" ""
    "_.chprop" "_last" "" "_layer" "HARDWARE" ""
  )
  (setvar 'osmode osm); return previous setting
)

 

It can get fancier, with an *error* handler to ensure Osnap modes get reset even if something goes wrong.

Kent Cooper, AIA
0 Likes