03-11-2024
01:13 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
03-11-2024
01:13 PM
Hi @darren.lees
Yes this can be tricky if you haven't debugged your own work extensively.
1/2. On Line 10 you declare an object as a style Then in line 11 set it as a string which is incorrect. Additionally the oNote object is only created in the function MoveText so this is also the incorrect position. What you wanted to do was to select a style object from the user interface drop down and this is sourced from the Drawing Document Text Styles collection.
Here is the code with the objects in the right place. I haven't tested it as you have it constructed but the style is being sourced from the right place and changed in a simple example I tried.
Sub Main()
Dim oDoc As Document
oDoc = ThisDoc.Document
Dim oNote As GeneralNote
Dim xTextPos As Double
Dim yTextPos As Double
Dim yTextPosDXF As Double
Dim oStlMgr As DrawingStylesManager = oDoc.StylesManager
Dim MyTextStyle As TextStyle
If oDoc.DocumentType = kDrawingDocumentObject Then
Select SheetSize
Case "A3"
oDoc.ActiveSheet.Size = DrawingSheetSizeEnum.kA3DrawingSheetSize
xTextPos = 1.5
yTextPos = xTextPos
yTextPosDXF = 28.25
MyTextStyle = oStlMgr.TextStyles.Item("Note Text LARGE (ISO)")
Case "A2"
oDoc.ActiveSheet.Size = DrawingSheetSizeEnum.kA2DrawingSheetSize
xTextPos = 1.5
yTextPos = xTextPos
yTextPosDXF = 40.5
MyTextStyle = oStlMgr.TextStyles.Item("Note Text LARGE (ISO)")
Case "A1"
oDoc.ActiveSheet.Size = DrawingSheetSizeEnum.kA1DrawingSheetSize
xTextPos = 2.75
yTextPos = xTextPos
yTextPosDXF = 56.75
MyTextStyle = oStlMgr.TextStyles.Item("Note Text (ISO)")
Case "A0"
oDoc.ActiveSheet.Size = DrawingSheetSizeEnum.kA0DrawingSheetSize
xTextPos = 2.75
yTextPos = xTextPos
yTextPosDXF = 81.5
MyTextStyle = oStlMgr.TextStyles.Item("Note Text (ISO)")
End Select
End If
MoveText(xTextPos, yTextPos, yTextPosDXF, MyTextStyle)
End Sub
Function MoveText(xPOS, yPOS, yPOSDXF, SetTextStyle)
Dim oNote As GeneralNote
If ActiveSheet.Size = "A1" Or ActiveSheet.Size = "A0" Then
For Each oNote In ThisDoc.Document.ActiveSheet.DrawingNotes.GeneralNotes
If oNote.Text.Contains("NOTES:") Then
oPoint = ThisApplication.TransientGeometry.CreatePoint2d(xPOS, yPOS)
oNote.Position = oPoint
oNote.TextStyle = SetTextStyle
End If
If oNote.Text.Contains("PACK REVISION") Then
oPoint = ThisApplication.TransientGeometry.CreatePoint2d(xPOS, yPOSDXF)
oNote.Position = oPoint
End If
Next
Else
For Each oNote In ThisDoc.Document.ActiveSheet.DrawingNotes.GeneralNotes
If oNote.Text.Contains("NOTES:") Then
oPoint = ThisApplication.TransientGeometry.CreatePoint2d(xPOS, yPOS)
oNote.Position = oPoint
oNote.TextStyle = SetTextStyle
End If
If oNote.Text.Contains("PACK REVISION") Then
oPoint = ThisApplication.TransientGeometry.CreatePoint2d(xPOS, yPOSDXF)
oNote.Position = oPoint
End If
Next
End If
End Function.
If this solved a problem, please click (accept) as solution.
Or if this helped you, please, click (like)
Regards
Alan
Or if this helped you, please, click (like)
Regards
Alan