|
DigiPara Liftdesigner LDX API
|
API method: ILDXSheetFrameTexts5.Add
Treename: Sheets.LdvSheet1.LdvFrame2.Map.NOTE#LD API example - Sheet frame text
2 code examples follow.
' from Samples/Src/LDXAPIExamples/Example_LDXSheetFrameTexts.vb
<APIHelpAttribute(APIHelpModes.FireCalcModel Or APIHelpModes.LoadLD3File, {APIHelpModes.InputParaLDXDoc}, "Sheets.LdvSheet1.LdvFrame2.Map.NOTE#LD API example - Sheet frame text", "LDXSheetFrameTexts~Add", "Add a text annotation")>
Public Shared Sub AddAText(ByRef ldxDocument As DigiPara.LDX.LDXDocument)
If ldxDocument.GetObject("Sheets.LdvSheet1.LdvFrame2.Map.") Is Nothing Then
MsgBox("Desired sheet frame texts frame not found! Please reload the relevant .ld3 file.")
Exit Sub
End If
Dim ldxSheetFrameTexts As DigiPara.LDX.LDXSheetFrameTexts = DirectCast(ldxDocument.GetLDXObject("Sheets.LdvSheet1.LdvFrame2.Map.").LDXType, DigiPara.LDX.LDXSheetFrameTexts)
Dim ldxSheetFrameText As DigiPara.LDX.LDXSheetFrameText = ldxSheetFrameTexts.Add("NOTE#LD API example - Sheet frame text")
With ldxSheetFrameText
' The display text
.Text = "LD API example text"
' Set mode of the sheet frame
.SheetFrameTextMode = DigiPara.LDX.SheetFrameTextModes.sftmBold Or DigiPara.LDX.SheetFrameTextModes.sftmBoxWidthFixed Or DigiPara.LDX.SheetFrameTextModes.sftmFrame
' Alignment of text
.Alignment = DigiPara.LDX.SheetFrameTextAlignmentType.sftaTopLeft
' Border color, width & height
.BorderColor = 150
.BoxWidth = 30
.BoxHeight = 50
.FontName = "Segoe UI Light"
' Space between lines
.LineSpaceFactor = 1.1
' Space between text and border
.Margin = 6
.TextColor = 200
.TextHeight = 7
' Position of the annotation
.RelativePosition = DigiPara.LDX.SheetFrameTextRelativePosition.sftpTop Or DigiPara.LDX.SheetFrameTextRelativePosition.sftpLeft
' The added quyntity to the X and Y coordinates of the location of the annotation
.X0 = -400
.Y0 = 400
End With
End Sub
' from Samples/Src/LDXAPIExamples/Example_LDXSheetFrameTexts.vb
<APIHelpAttribute(APIHelpModes.FireCalcModel Or APIHelpModes.LoadLD3File, {APIHelpModes.InputParaLDXDoc}, "Sheets.LdvSheet1.LdvFrame2.Map.Shaft0.Car.", "LDXSheetFrameTexts~Add", "Add a component annotation")>
Public Shared Sub AddComponentAnnotation(ByRef ldxDocument As DigiPara.LDX.LDXDocument)
If ldxDocument.GetObject("Sheets.LdvSheet1.LdvFrame2.Map.") Is Nothing Then
MsgBox("Desired sheet frame texts frame not found! Please reload the relevant .ld3 file.")
Exit Sub
End If
Dim ldxSheetFrameTexts As DigiPara.LDX.LDXSheetFrameTexts = DirectCast(ldxDocument.GetLDXObject("Sheets.LdvSheet1.LdvFrame2.Map.").LDXType, DigiPara.LDX.LDXSheetFrameTexts)
' if an annotiation is already present, it is returned
Dim ldxSheetFrameText As DigiPara.LDX.LDXSheetFrameText = ldxSheetFrameTexts.Add("Shaft0.Car.")
With ldxSheetFrameText
' if you're reading this, start with "Case Else", that runs first
Select Case .Text
Case "Car annotation (rerun sample for other options)"
.Text = "Car annotation with base point"
' set reference point (rear left corner)
.PGP_CODE_NO = 9017
Case "Car annotation with base point"
.Text = "Car annotation with modified positions"
.PGP_CODE_NO = 0
' you can modify the box position (units are world units, but directions are in drawing space)
.X0 = 1500
.Y0 = 1000
' and the arrow head position
.ArrowX0 = 555
.ArrowY0 = -432
Case "Car annotation with modified positions"
.Text = "Car annotation with rule based positions"
.PGP_CODE_NO = 0
' you can modify the positions by rules, too. "Me." is the pointed to object
.SheetFrameTextMode = .SheetFrameTextMode Or DigiPara.LDX.SheetFrameTextModes.sftmUseRuleForArrowPosition Or DigiPara.LDX.SheetFrameTextModes.sftmUseRuleForBoxPosition
.X0_RULE = "1000"
.Y0_RULE = "LD(""Me.CD"")*.2"
.ArrowX0_RULE = "0"
.ArrowY0_RULE = "LD(""Me.CW"")*.5"
Case "Car annotation with rule based positions"
.Text = "Car annotation on top"
' change position so annotation is on top
.RelativePosition = DigiPara.LDX.SheetFrameTextRelativePosition.sftpTop
Case "Car annotation on top"
.Text = "Car annotation with leader line forced to the right"
' change leader line relevant flags
.SheetFrameTextMode = (.SheetFrameTextMode And Not DigiPara.LDX.SheetFrameTextModes.sftmLeaderLinePositionMask) Or DigiPara.LDX.SheetFrameTextModes.sftmLeaderLinePositionRight
Case "Car annotation with leader line forced to the right"
.Text = "Circle :)"
' we found this in the code recently for version 2025.1. It has been possible all the way back in version 5.
.SheetFrameTextMode = .SheetFrameTextMode Or DigiPara.LDX.SheetFrameTextModes.sftmCircle
Case "Circle :)"
' start over
.Object.RemoveMe()
Case Else
' Set the display text
.Text = "Car annotation (rerun sample for other options)"
' activate leader line
.SheetFrameTextMode = .SheetFrameTextMode Or DigiPara.LDX.SheetFrameTextModes.sftmLeaderLine
' better position
.X0 = 1500
End Select
' or with rules (.X/Y0_RULE and .ARROW_X/Y exist as alternatives)
.ArrowX0_RULE = "LD(""Me.CW"")*.5"
' the arrow head position is relative to the component reference point
End With
End Sub