LISP TO DRAW LINES FROM POINT TO POINT NEED IT TO AUTO JOIN TO NEXT POINT

LISP TO DRAW LINES FROM POINT TO POINT NEED IT TO AUTO JOIN TO NEXT POINT

jlicerioAQQLC
Contributor Contributor
2,019 Views
35 Replies
Message 1 of 36

LISP TO DRAW LINES FROM POINT TO POINT NEED IT TO AUTO JOIN TO NEXT POINT

jlicerioAQQLC
Contributor
Contributor

; lisp to draw hor lines plus 45's between 2 points
; By BIGAL Jan 2012
(defun c:1()
(vl-load-com)
(setq pt1 (getpoint "\npick 1st point on terminal bar"))
(setq pt2 (getpoint "\npick 2nd point "))
; ang2 is horiz lines ang3 is 45 lines
(setq ang1 (angle pt1 pt2))
(setq ang2 0.0)(setq ang3 (* 0.5 pi))
(setq pt3 (polar pt1 ang2 20.0))
(setq pt4 (polar pt2 ang3 20.0))
(setq pt5 (inters pt1 pt3 pt2 pt4 nil))
(command "pline" pt1 pt5 pt2 "")
)
(princ)

0 Likes
Accepted solutions (2)
2,020 Views
35 Replies
Replies (35)
Message 21 of 36

jlicerioAQQLC
Contributor
Contributor

Polyline auto generates from block to block? 

0 Likes
Message 22 of 36

Kent1Cooper
Consultant
Consultant
Accepted solution

@jlicerioAQQLC wrote:

What I'm trying to get is a lisp code that is continuous pline this one I'm using only goes from point a to point b and then I have to make a new line.


It seems the 45° element is a red herring.  The Polyline part with continuation [no numbering yet] can be much simpler, I think -- for the version that goes horizontally from the 1st point to a corner and then vertically to the second [#1], try this:

 

(defun C:LPCHV ; = Link Points Continuously, Horizontal then Vertical
  (/ pt1 pt2)
  (command "_.pline" (setq pt1 (getpoint "\nStarting point: ")))
  (while (setq pt2 (getpoint "\nNext point: "))
    (command "_non" (list (car pt2) (cadr pt1)) "_non" (setq pt1 pt2))
  ); while
  (command "")
  (princ)
)

 

To go vertically first, then horizontally [#2], simply change (list (car pt2) (cadr pt1)) to (list (car pt1) (cadr pt2))  [and change the command name and description].  Other variants can be made easily enough [#3 & #4 -- LL doesn't require any code].

 

You need to pick the points [Osnap to INSertion points if appropriate].  It could be made to ask you to select Blocks instead, and it could find their insertion points.  That is, assuming the insertion points are the locations in the Blocks that you want the Polyline to connect.

Kent Cooper, AIA
Message 23 of 36

ronjonp
Mentor
Mentor

Nope. Post a drawing with what you're starting out with and the end result desired.

Message 24 of 36

jlicerioAQQLC
Contributor
Contributor
Very nice attribute numbering script how could I specify to a specific attribute I tried it and it changed all the attributes on the block. just.
0 Likes
Message 25 of 36

jlicerioAQQLC
Contributor
Contributor

Amazing work better than the ones I'm currently using.

0 Likes
Message 26 of 36

Kent1Cooper
Consultant
Consultant

@jlicerioAQQLC wrote:

.... the line has to be joined to get the length of the wire.


That raises a question in my mind:  In reality, how likely is it that "the wire" will be run in nice straight and orthogonal and like-your-1-through-4-image arrangements?  In other words, however it may be drawn, what relevance can that really have to the actual total length of "the wire"?  And in addition to the question of the "path" it would follow in plan, would there not also be a vertical component at least in some places, that would add to the plan length?

Kent Cooper, AIA
0 Likes
Message 27 of 36

jlicerioAQQLC
Contributor
Contributor

Yes, it can be both horizontal and vertical how would that be added it was a typo of mine the main problem for me was generating the line from block to block? The way I've been trained in fire alarm design is by drawing and calculating the length this way. You would say it is inefficient how can this be better?

0 Likes
Message 28 of 36

ronjonp
Mentor
Mentor

@jlicerioAQQLC wrote:
Very nice attribute numbering script how could I specify to a specific attribute I tried it and it changed all the attributes on the block. just.

Add this line to the code:

ronjonp_0-1663964607176.png

 

Message 29 of 36

jlicerioAQQLC
Contributor
Contributor
I read where you posted the script that I just change values To go vertically first, then horizontally [#2], simply change (list (car pt2) (cadr pt1)) to (list (car pt1) (cadr pt2)) [and change the command name and description]. Is there a way to make it all in one script.
0 Likes
Message 30 of 36

Kent1Cooper
Consultant
Consultant

@jlicerioAQQLC wrote:

.... You would say it is inefficient how can this be better?


Not so much inefficient as inaccurate, if the intent is to know how much length of wire you need to hook it all up.  A better approximation would count the number of vertices in the resulting Polyline, which from that command will always be odd, divide it in half and round up, and that will give you the number of picked points, presumably the number of alarm elements.  If there is a known elevation at which those are mounted, and it's all otherwise wired at some known elevation above the ceiling [if that can be assumed to be constant], you could then take the difference between those elevations, and add twice that for each picked point [to get down to the element and back up], plus some "tail" length to make the connections at the presumed electrical box.  Not knowing how the end(s) of it all would relate to whatever it needs to connect back to [FACP, power source, etc.], or whether whatever-that-is would be included in the route-drawing operation, I couldn't say whether that would tell the whole story.  And there's the complication that [I assume] some of those locations are horn-and-strobe alarms or the like, and some are pull stations, which would not be at the same mounting height.

Kent Cooper, AIA
0 Likes
Message 31 of 36

Kent1Cooper
Consultant
Consultant

@jlicerioAQQLC wrote:
I read where you posted the script that I just change values To go vertically first, then horizontally .... Is there a way to make it all in one script.

[It's not a Script.  That word has a specific but different (though related) meaning in AutoCAD, and this isn't it.]

Do you mean one AutoLisp file that defines more than one command?  Or maybe one command that asks you which direction you want to go first from each point in heading toward the next one?  Or maybe one command that always heads first in the direction of the greater X-or-Y difference between the points?  Or something else?

Kent Cooper, AIA
0 Likes
Message 32 of 36

jlicerioAQQLC
Contributor
Contributor
Yes, a command that gives you the option of which direction would make it more seamless. would the xy difference make it more seamless? Or would it run into complications? I would need to test and see .
0 Likes
Message 33 of 36

jlicerioAQQLC
Contributor
Contributor

Yeah, my devices do have attributes with wire drop and reduction most of the plans we get are 2d so I add that to my calculations on excel using attout command.

jlicerioAQQLC_0-1663967002066.png

 

0 Likes
Message 34 of 36

ВeekeeCZ
Consultant
Consultant
Accepted solution

@jlicerioAQQLC wrote:
I read where you posted the script that I just change values To go vertically first, then horizontally [#2], simply change (list (car pt2) (cadr pt1)) to (list (car pt1) (cadr pt2)) [and change the command name and description]. Is there a way to make it all in one script.

 

If you have Express Tools installed, you can use this func to toggle the behavior by holding CTRL.

 

(defun C:LPC ; = Link Points Continuously, Horizontal then Vertical
  (/ pt1 pt2)
  (command "_.pline" (setq pt1 (getpoint "\nStarting point: ")))
  (while (setq pt2 (getpoint "\nNext point: "))
    (if (acet-sys-control-down)
      (command "_non" (list (car pt1) (cadr pt2)))
      (command "_non" (list (car pt2) (cadr pt1))))
    (command "_non" (setq pt1 pt2))
  ); while
  (command "")
  (princ)
)

 

0 Likes
Message 35 of 36

Kent1Cooper
Consultant
Consultant

@jlicerioAQQLC wrote:
Yes, a command that gives you the option of which direction would make it more seamless. would the xy difference make it more seamless? .....

I'm realizing that there may be no reliably "more seamless" approach.  It all depends on the positional relationships and from which location you start a given connection.  For example, whether you  1)  use an explicit always-go-horizontal-first command or  2)  have it take the greater-difference direction first, in this A/B situation, if it goes from A to B you'll get the red, but if it goes from B to A you'll get the green:

Kent1Cooper_0-1664208928319.png

I've been trying to figure out what kind of criteria could be established that would give you some kind of consistency, and what would define "consistency."  Might you, for example, always want whichever route is "upper" vs. "lower" [in the image, always the red, regardless of the order], or vice versa?  That may not always be the right solution, either, for example in this A/B/C situation:

Kent1Cooper_1-1664209819042.png

if you always want the "upper" route, you'll get the red and yellow, which coincide at B -- is that a problem?  You might want the red and the cyan, or the green and the yellow.  But how a routine could be made to figure that out is hard to imagine.  Maybe it could be made to keep track of which direction it ended with at the last connection, and go the other way for the next one.  Or should it enforce that change in starting direction only when both the previous and following positions are higher [or lower] than the current one?  And then figure the same kind of thing in a path moving generally in a vertical direction, and of course there will be routes that double back in either X or Y direction, etc., etc.

Kent Cooper, AIA
Message 36 of 36

jlicerioAQQLC
Contributor
Contributor

Yeah, what if the routine would draw all the possible plines to view the routes after giving you a choice to click on the one you want to keep? Or perhaps a toggle function through each possible route .

0 Likes