getpoint method

getpoint method

Anonymous
Not applicable
552 Views
3 Replies
Message 1 of 4

getpoint method

Anonymous
Not applicable

Every drawing wchich I write in VBA
and I want to start begins with command getpoint
I press F5 to compile. Autocad ask me
:please insert point
[ I use procedure
 pktP0 = .GetPoint(, vbCr & "Pick the start point: ")  ]
 and from that point i create other points using polarpoint method
isoA1hp1pos = .PolarPoint(pktP0, k0Deg, od140p)  

Is there a possibility that this first point i set in vba program
and I don't have to every time click on the autocad screen indicate
first point   pktP0

I wrote program which doesn't work.Please correct him

Public Sub liniaz2punktow()
'I would like to set 1 point in Autocad and create another points
' from that point
' how to this this ?

With ThisDrawing.Utility

Dim Object As AcadPoint
Dim Here As Variant


Dim varP1 As Variant
Dim varP2 As Variant

Dim k0Deg As Double

Dim dbLpionL As Double 'podaje wartosc liczbowa


k0Deg = .AngleToReal("0d", acDegrees)

Here(0) = 2: Here(1) = 1: Here(2) = 0

dbLpionL = 500

varP2 = .PolarPoint(Here, k0Deg, dbLpionL)

ThisDrawing.ModelSpace.AddLine Here, varP2

End With
End Sub

0 Likes
553 Views
3 Replies
Replies (3)
Message 2 of 4

Hallex
Advisor
Advisor

Probably you need to create separate function to add your entities

based on previously defined base point

Then you can call it in the main sub

Something like this

Public Function AddLineToSpace(firstPoint As Variant, angle As Double, dist As Double) As AcadLine

Dim secondPoint As Variant
With ThisDrawing
With .Utility
secondPoint = .PolarPoint(firstPoint, angle, dist)
End With
With .ModelSpace
Set AddLineToSpace = .AddLine(firstPoint, secondPoint)
End With
End With

End Function

Public Sub main()

Dim pi As Double
pi = Atn(1#) * 4
Dim p1(0 To 2) As Double
p1(0) = 0: p1(1) = 0: p1(2) = 0
Dim ang As Double
ang = pi / 4 '45 degrees
Dim dist As Double
dist = 1000#
Dim oLine As AcadLine
Set oLine = AddLineToSpace(p1, ang, dist)
'change some properties here
oLine.color = acRed
End Sub

 

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
0 Likes
Message 3 of 4

Anonymous
Not applicable

thank You for help

it works

0 Likes
Message 4 of 4

Hallex
Advisor
Advisor

You're welcome

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
0 Likes