
Originally Posted by
victos
Hi,
I have a problem because I can not calculate correctly point P2 relative to local coordinate system.
The point is that the user indicates the P1 and P2 from P1 is located about 100 units in the axis X. How to draw a line from P1 to P2 but in a local coordinate system?
Please help
http://www.cadtutor.net/forum/showthread.php?55396-VBA-UCS-problem-draw-line-3dpolyline&p=375370#post375370[/img]
See if this helps
Sorry no explantion
Code:
Sub Demo()
Dim currUCS As AcadUCSs
' naming current UCS is not have a name
On Error Resume Next '<-- to bypass if exist or (if ThisDrawing.GetVariable("ucsname") return empty string)
With ThisDrawing
Set currUCS = .UserCoordinateSystems.Add( _
.GetVariable("UCSORG"), _
.Utility.TranslateCoordinates(.GetVariable("UCSXDIR"), acUCS, acWorld, 0), _
.Utility.TranslateCoordinates(.GetVariable("UCSYDIR"), acUCS, acWorld, 0), _
"BoxUCS")
.ActiveUCS = currUCS '<--set as current UCS
If Err Then Err.Clear
On Error GoTo 0
ZoomAll '<--optional, just for debugging
Dim ortho As Variant
ortho = .GetVariable("orthomode")
.SetVariable "orthomode", 1 '<--set orthomode to ON
Dim firstPoint As Variant
Dim secondPoint As Variant
Dim firstPontUcs As Variant
firstPoint = .Utility.GetPoint(, "Enter a point: ") ''<--GetPoint is always return WCS coordinates of the point the AutoCAD user has selected.
firstPontUcs = .Utility.TranslateCoordinates(firstPoint, acWorld, acUCS, False) '' <-- convert coordinates to current UCS just for dysplaying the rubber band correctly
secondPoint = .Utility.GetPoint(firstPontUcs, "Specify second point: ")
Dim lineObj As AcadLine
Set lineObj = .ModelSpace.AddLine(firstPoint, secondPoint)
.SetVariable "orthomode", ortho
End With
End Sub
fixo