TheSwamp

Code Red => VB(A) => Topic started by: Matersammichman on September 16, 2008, 01:55:29 PM

Title: Draw Pline relative to user-selected point
Post by: Matersammichman on September 16, 2008, 01:55:29 PM
I'm using Getpoint to ID an x,y,z position in space.
I want to be able to draw a Pline at a user-define distance and angle relative to my selected point (as in "@23<45).

Anyone know a way to do this?
Title: Re: Draw Pline relative to user-selected point
Post by: Bryco on September 16, 2008, 09:21:12 PM
sin and cos should get you there
Title: Re: Draw Pline relative to user-selected point
Post by: Bryco on September 16, 2008, 09:57:41 PM
Code: [Select]
Sub plineinput()

Dim p As AcadLWPolyline
Dim p1, pts(3) As Double
Dim dist As Double, ang As Double
Dim util As AcadUtility
Dim x As Double, y As Double

Set util = ThisDrawing.Utility
p1 = util.GetPoint(, "Pick")
dist = util.GetReal("Length")
ang = util.GetReal("Angle")
ang = ang * Pi / 180 'degrees TO RADIANS
x = Cos(ang) * dist
y = Sin(ang) * dist
pts(0) = p1(0): pts(1) = p1(1)
pts(2) = p1(0) + x: pts(3) = p1(1) + y
Set p = ThisDrawing.ModelSpace.AddLightWeightPolyline(pts)

End Sub

To use "@23<45" you need to parse  a string return
Title: Re: Draw Pline relative to user-selected point
Post by: Matersammichman on September 17, 2008, 12:14:05 PM
Thanks Bryco!
Title: Re: Draw Pline relative to user-selected point
Post by: Bryco on September 17, 2008, 07:39:59 PM
You are welcome.
Title: Re: Draw Pline relative to user-selected point
Post by: SomeCallMeDave on September 18, 2008, 02:23:33 PM
ThisDrawing.Utility.PolarPoint might be an option too,  if I understand the problem correctly