Author Topic: Draw Pline relative to user-selected point  (Read 2415 times)

0 Members and 1 Guest are viewing this topic.

Matersammichman

  • Guest
Draw Pline relative to user-selected point
« 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?

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Draw Pline relative to user-selected point
« Reply #1 on: September 16, 2008, 09:21:12 PM »
sin and cos should get you there

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Draw Pline relative to user-selected point
« Reply #2 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

Matersammichman

  • Guest
Re: Draw Pline relative to user-selected point
« Reply #3 on: September 17, 2008, 12:14:05 PM »
Thanks Bryco!

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Draw Pline relative to user-selected point
« Reply #4 on: September 17, 2008, 07:39:59 PM »
You are welcome.

SomeCallMeDave

  • Guest
Re: Draw Pline relative to user-selected point
« Reply #5 on: September 18, 2008, 02:23:33 PM »
ThisDrawing.Utility.PolarPoint might be an option too,  if I understand the problem correctly