Jump to content

Line on a Polyline


bhargav1987

Recommended Posts

I Just want to know is there any possibility to draw a polyline on a different polyline from half distance from starting point and half distance from ending point of polyline????

 

 

I know tat my question is peculiar one :shock:..

 

but i want to know the way..if it can be done..

 

Expecting help :(

Link to comment
Share on other sites

... from half distance from starting point and half distance from ending point of polyline????

 

 

you mean the Midpoint of the line? Do you use OSnaps? if not, turn them on with the F3-key, then go into OSnap settings (Tools > Drafting Settings > Obejct Snap tab) and tick Midpoint.

 

dang, beat by the Tinman :wink:

Link to comment
Share on other sites

Half the distance from each end of a line is the midpoint isn't it?

Ya..ReMark..U r right...But i want to convey is half the distance from oneend is midpoint tat's true..

But i want to draw line from tat midpoint to say to length 0.5,along the polyline..using VBA

Can u help me with this??

Link to comment
Share on other sites

you mean the Midpoint of the line? Do you use OSnaps? if not, turn them on with the F3-key, then go into OSnap settings (Tools > Drafting Settings > Obejct Snap tab) and tick Midpoint.

 

dang, beat by the Tinman :wink:

Ya..Tiger..U r right..But i want to do it using vba

Link to comment
Share on other sites

Wat i understtod is you need to draw a polyline start/end from 1/3rd of that polyline length from both side. i.e) the new polyline length will be half of the original one. Am i correct? otherwise, Please explain clearly.If possible provide an image.

Link to comment
Share on other sites

Ya..ReMark..U r right...But i want to convey is half the distance from oneend is midpoint tat's true..

But i want to draw line from tat midpoint to say to length 0.5,along the polyline..using VBA

Can u help me with this??

 

urgh...not to complain too much, but all this text-speek makes your post pretty unreadable for me.

 

I can't help with VBA, and to be fair you did not say that you wanted a VBA-solution in the original post, but to find the midpoint of two points you can use the OSnap M2P (no tickbox for it, have to type M2P at the commandline while the command is active) as well, that might be more what you are looking for.

Link to comment
Share on other sites

Can you tell us what the point of this little exercise is? Is there an overriding need to reinvent the wheel to locate the midpoint of one line to start a second line? What do you mean by drawing along the line? Next to it or on top of it? And what would be the point of drawing one line atop another? Isn't this something we try to avoid as CAD users?

Link to comment
Share on other sites

Wat i understtod is you need to draw a polyline start/end from 1/3rd of that polyline length from both side. i.e) the new polyline length will be half of the original one. Am i correct? otherwise, Please explain clearly.If possible provide an image.

 

Ya..u r correct..

I have attached an image in tat one red line is already drawn....

i want to draw another polyline of cyan colour..

 

So...automatically by vba...on click of red line..i want to draw cyan line..

 

Hope now i said it clearly

1.jpg

Link to comment
Share on other sites

Not up to answering my other questions I see. Oh well. On to more pressing matters. Good day.

 

Note: It is not good drafting practice to draw one line atop another like you have shown.

Link to comment
Share on other sites

Not up to answering my other questions I see. Oh well. On to more pressing matters. Good day.

 

Note: It is not good drafting practice to draw one line atop another like you have shown.

i can't understand wat u r saying remark..

wat actually i want is if as shown in image if byclicking one line if it possible to draw another line on it..it will help me a lot...

 

Tell me the possibility please

Link to comment
Share on other sites

If is about a line may use the code below to get his middle point; for a polyline will be quite elaborate:

 

Point1st = MyLine.StartPoint
Point2nd = MyLine.EndPoint
theAngle = MyLine.Angle

ReDim Point3rd(2)
Point3rd(0) = 0.5 * (Point1st(0) + Point2nd(0))   'X
Point3rd(1) = 0.5 * (Point1st(1) + Point2nd(1))   'Y
Point3rd(2) = 0.5 * (Point1st(2) + Point2nd(2))   'Z

 

Regards,

Link to comment
Share on other sites

  • 2 weeks later...
If is about a line may use the code below to get his middle point; for a polyline will be quite elaborate:

 

Point1st = MyLine.StartPoint
Point2nd = MyLine.EndPoint
theAngle = MyLine.Angle

ReDim Point3rd(2)
Point3rd(0) = 0.5 * (Point1st(0) + Point2nd(0))   'X
Point3rd(1) = 0.5 * (Point1st(1) + Point2nd(1))   'Y
Point3rd(2) = 0.5 * (Point1st(2) + Point2nd(2))   'Z

 

Regards,

Thanks for reply...

But i want to do it on a polyline....

the vb u have given gives only midpoint right??

But wat i actually want is to draw a line to a particular length on a polyline for some distance...

Pls help me with this

Link to comment
Share on other sites

Presuming a XoY polyline with two vertexes:

 

PlineVertexes = MyPLine.Coordinates

DeltaX = PlineVertexes(3) - PlineVertexes(0)   'displacement on X
DeltaY = PlineVertexes(4) - PlineVertexes(5)   'displacement on Y

If DeltaX = 0 Then
   theAngle = 0.5 * pi                        '90 degrees
Else
   theAngle = Atn(DeltaY / DeltaX)            'polyline's angle
End If

ReDim Point3rd(2)                              'middle point
Point3rd(0) = 0.5 * (PlineVertexes(3) + PlineVertexes(0))   'X
Point3rd(1) = 0.5 * (PlineVertexes(4) + PlineVertexes(5))   'Y
Point3rd(2) = 0#                                            'Z

'calculate new angle by adding or subtracting 90 degrees
NewAngle = theAngle + 0.5 * pi                 'LEFT side
'NewAngle = theAngle - 0.5 * pi                 'RIGHT side

'calculate the new point at arbitrary distance (1 unit)
NewDistance = 1
ReDim Point4th(2)                              'new point
Point4th(0) = Point3rd(0) + NewDistance * Cos(NewAngle)
Point4th(1) = Point3rd(1) + NewDistance * Sin(NewAngle)
Point4th(2) = 0#

ThisDrawing.ModelSpace.AddLine Point3rd, Point4th

 

Regards,

Link to comment
Share on other sites

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