Macro draw line parallel to two points with 3 segments

Macro draw line parallel to two points with 3 segments

Anonymous
Not applicable
3,003 Views
34 Replies
Message 1 of 35

Macro draw line parallel to two points with 3 segments

Anonymous
Not applicable
Hi All

I am trying to use the below macro to draw a line with 3 segments that connects two points, the middle segment runs parrallel and offset to the points and the first and third segments join to each point at either end . The points are of a variable distance. My idea is redefine the ucs along the vector of the points and then select the second point(block) to define LASTPOINT then use the userr1-5 variables to draw the desired polyline but its not quiet working out.

^C^CUCS;\\;SELECT;SI;\setvar;USERR1;$M=$(index,0,$(GETVAR,LASTPOINT));setvar;USERR4;1.156;setvar;USERR3;$(-,$(getvar,USERR2)(,$(getvar,USERR4));PLINE;0,0;@0,1.156;@0,$(GETENV,USERR3);@0,-1.156;


Hopefully someone can advise as to my mistakes and help me learn a bit more.


Regards

0 Likes
Accepted solutions (1)
3,004 Views
34 Replies
Replies (34)
Message 2 of 35

pendean
Community Legend
Community Legend
Post a screenshot of the final result you are trying to achieve, and in it explain what exactly would change (and by what governing factor).

FWIW I believe the variable LASTPOINT cannot call a point from inside the same macro.
0 Likes
Message 3 of 35

Anonymous
Not applicable
I am not at a desk top right now. The only variable is the distance between
the two points(or blocks) . Are you sure? if i select Single SI and object
does this not define the lastpoint and then allow me index the first
section of it.


0 Likes
Message 4 of 35

steven-g
Mentor
Mentor

I am having a hard time visualising the shape of this 3 sided object, sould it be "U" shaped with the open end the two pick points and the underside offset from those points, or is it something else because your macro contains fixed numbers. The si option of select is used to make a single selection set not a single point, which is confusing. Some visual help on this one will help greatly. And to clarify lastpoint is fine within a macro, but storing and then using variables can be problematic.

0 Likes
Message 5 of 35

Anonymous
Not applicable
Yes thats it exactly as you descibed like a "u" shape.
If i select a circular block with a base point in the centre it sets
lastpoint as the base point. The other block is my ucs point (0,0,0) and
the ucs x plane is aligned along the vector between the two points or
blocks, i now have the distance between points which i can use to draw the
second segment of the polyline.
0 Likes
Message 6 of 35

steven-g
Mentor
Mentor

and what is the significance of the 1.156 and -1.156

0 Likes
Message 7 of 35

pendean
Community Legend
Community Legend
We sure could use an image to show us what you are drawing (and why)...

Also, are you using the term "block" as in the specific AutoCAD use of the term, or is it a generic meaning?
0 Likes
Message 8 of 35

Anonymous
Not applicable
When i get to a desktop i will post an image. Block as in the AutoCAD
version. I want to draw mutiple lines between 2 points ,max 5, and i am
sick of drawing a single line between two points then having to offset and
add vertices and join the end points back to the points. Its about visually
representing multiple connections between a set of points. Like say 5
different wires between a switch. If i can get one that offsets
automatically and returns i can offset that And it will make things easier.
0 Likes
Message 9 of 35

steven-g
Mentor
Mentor

Here's a starter

 

^C^Cortho;off;pline;\\;UCS;ob;l;ortho;on;pe;l;e;i;@;n;i;@;x;;

It draws a 3 segment polyline between 2 points and aligns the ucs to that polyline, a macro won't allow a selection to remain highlighted as it finishes. So you need to run the macro (pick your two points). And then go back and select the new polyline and stretch the middle grip where you need it. Not 100% yet but when you post some more info it might help improve on the idea.

Message 10 of 35

pendean
Community Legend
Community Legend
>>>>..Like say 5 different wires between a switch...<<<
Any reason these cannot be 5-different blocks you just insert when you need them? How many variations are there truly likely to be?
0 Likes
Message 11 of 35

john.uhden
Mentor
Mentor

Are you running AutoCAD LT or a full version that supports AutoLisp?

If the latter, then it's very simple.  Is the offset always a constant value, or do you want to be prompted to enter a value?  Do you want the polyline to be created on a certain layer, or just use the current layer?

John F. Uhden

0 Likes
Message 12 of 35

Anonymous
Not applicable
The switch and wire was an example i used to give some idea this is not
actually what i use it for. The direction and length of the lines between
points are always different.

Going back to my original post am i completely off? or is it something that
could potentially work


I am running autoCAD lt.

i have attached an image showing what my end result is. the original
distance of 1.156 was the suitable length of the first and last segment


[image: Inline image 1]
0 Likes
Message 13 of 35

john.uhden
Mentor
Mentor

My apologies to you.  If you are running only LT, I can't help you.

John F. Uhden

0 Likes
Message 14 of 35

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:
....
i have attached an image ....

[image: Inline image 1]

The image didn't come through....  But in the meantime, I notice in Post 1 that you seem to be using USERR2 without having set it, and that you have a GETENV that I suspect ought to be GETVAR.

Kent Cooper, AIA
0 Likes
Message 15 of 35

Anonymous
Not applicable

Capture.PNG

 

 Thanks for the help so far guys. @steven-g i have used yours and it is almost what i need but it would be ideal if i could have it more like above. When you initiate the add vertex command can i specify where to put the new vertices along the line. 

 

See above this is what i need if possible. 

0 Likes
Message 16 of 35

steven-g
Mentor
Mentor

This macro

^C^Cortho;off;pline;\\;UCS;ob;l;ortho;on;pe;l;e;i;\i;\;x;;

Would allow you to select 4 points in the order shown below

 

Pick4.jpg

0 Likes
Message 17 of 35

Anonymous
Not applicable

 

Thanks @steven-g after playing around with yours i came up with this which is what i need 

 

^C^Cortho;off;pline;\\;UCS;ob;l;ortho;on;pe;l;e;i;@1,1;x;r;e;i;@-1,1;x;;ucs;w

Message 18 of 35

Anonymous
Not applicable
Spoke too soon 🙂 it only works in certain directions
0 Likes
Message 19 of 35

steven-g
Mentor
Mentor

What do you mean by that "certain directions"

0 Likes
Message 20 of 35

Anonymous
Not applicable
Try it your self and draw multiple lines in different directions , i get varying results sometimes the line is inverted and other times it works.
0 Likes