|
DigiPara Liftdesigner LDX API
|
API method: ILDXView5.PickPoint
' from Samples/Src/LDXAPIExamples/Example_LDXView.vb
Sub HandlePointPicked(frame As DigiPara.LDX.LDXSheetFrame, point As DigiPara.LDX.LDXHideVec)
' memorize drawing coordinates
Dim drawingX As Double = point.X
Dim drawingY As Double = point.Y
' transform to world coordinates
frame.CalculatePaperToWorld(point)
MsgBox(String.Format("Drawing Coordinates: ({0}, {1})" + Environment.NewLine + "World Coordinates: ({2}, {3}, {4})", drawingX, drawingY, point.X, point.Y, point.Z))
End Sub
Sub HandlePointPickCanceled()
MsgBox("Pick point canceled")
End Sub
End Class
' to keep the handler from getting GCed; apparrently in VB events do not own the objects handling them.
Shared m_handler As PickPointHandler
<APIHelpAttribute(APIHelpModes.LoadLD3File, {APIHelpModes.InputParaLDXDoc}, "", "LDXView~PickPoint", "Pick a point")>
Public Shared Sub PickPoint(ByRef ldxDocument As DigiPara.LDX.LDXDocument)
If ldxDocument.GetLDXObject("Sheets.LdvSheet1.LdvFrame2.") Is Nothing Then
MsgBox("Desired sheet not found. Please reload the relevant .ld3 file.")
Exit Sub
End If
ldxDocument.Sheets(1).Activate()
ldxDocument.GetLDXObject("Sheets.LdvSheet1.LdvFrame2.").GetLDXType(DigiPara.LDX.ObjectId.idSheetFrame)?.Activate()
MsgBox("Please select a point")
' optional argumenrt to PickPoint: name of cursor during operation (a DWG block in the prototype DWG)
Dim pick = ldxDocument.Sheets.ActiveSheet.View.PickPoint("LD_CURSOR_MEASURE_0")
If pick IsNot Nothing Then
m_handler = New PickPointHandler
' when the point is picked, the PointPicked event is raised
AddHandler pick.PointPicked, AddressOf m_handler.HandlePointPicked
' if the operation is canceled, for instance because another pick is started, the Canceled event is raised instead
AddHandler pick.Canceled, AddressOf m_handler.HandlePointPickCanceled
End If
' no need to unregister any events for this function; the registrations die with the 'pick' object at the
' end of the pick operation.
' PickPoint operates asynchronouslty, operation here continues and one of the events is triggered sometime later
End Sub