Message 1 of 4

Not applicable
07-13-2017
08:24 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I am looking for a way to create text in an .idw using iLogic. I've already searched the program's help menu and programming guides, found a code that is even referenced in the forums here from 2014, but the code in each instance is no longer supported in v2018. Sample of the code is below:
Sub SketchTextAdd() ' Set a reference to the drawing document. ' This assumes a drawing document is active. Dim oDrawDoc As DrawingDocument Set oDrawDoc = ThisApplication.ActiveDocument ' Create a new sketch on the active sheet. Dim oSketch As DrawingSketch Set oSketch = oDrawDoc.ActiveSheet.Sketches.Add ' Open the sketch for edit so the text boxes can be created. ' This is only required for drawing sketches, not part. oSketch.Edit Dim oTG As TransientGeometry Set oTG = ThisApplication.TransientGeometry ' Create text with simple string as input. Since this doesn't use ' any text overrides, it will default to the active text style. Dim sText As String sText = "Drawing Notes" Dim oTextBox As TextBox Set oTextBox = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(3, 18), sText) ' Create text using various overrides. sText = "Notice: All holes larger than 0.500 n are to be lubricated." Set oTextBox = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(3, 16), sText) ' Create a set of notes that are numbered and aligned along the left. Dim dYCoord As Double dYCoord = 14 Dim dYOffset As Double Dim oStyle As TextStyle Set oStyle = oSketch.TextBoxes.Item(1).Style dYOffset = oStyle.FontSize * 1.5 ' Simple single line text. Set oTextBox = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(3, dYCoord), "1.") sText = "This is note 1." Set oTextBox = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(4, dYCoord), sText) ' Two line text. The two lines are defined using the tag within the text string. dYCoord = dYCoord - (oTextBox.FittedTextHeight + 0.5) Set oTextBox = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(3, dYCoord), "2.") sText = "This is note 2, which contains two lines." Set oTextBox = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(4, dYCoord), sText) ' Single line of text. dYCoord = dYCoord - (oTextBox.FittedTextHeight + 0.5) Set oTextBox = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(3, dYCoord), "3.") sText = "This is note 3." Set oTextBox = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(4, dYCoord), sText) ' Three lines of text. dYCoord = dYCoord - (oTextBox.FittedTextHeight + 0.5) Set oTextBox = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(3, dYCoord), "4.") sText = "This is note 4, which contains several lines." Set oTextBox = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(4, dYCoord), sText) ' The number of this line of text will have a triangle around it. dYCoord = dYCoord - (oTextBox.FittedTextHeight + 0.5) Set oTextBox = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(3, dYCoord), "5") ' Draw a triangle that fits around a text box. Dim Points(1 To 3) As Point2d Call CalculateTriangle(oTextBox, Points) Dim oLines(1 To 3) As SketchLine Set oLines(1) = oSketch.SketchLines.AddByTwoPoints(Points(1), Points(2)) Set oLines(2) = oSketch.SketchLines.AddByTwoPoints(oLines(1).EndSketchPoint, Points(3)) Set oLines(3) = oSketch.SketchLines.AddByTwoPoints(oLines(2).EndSketchPoint, oLines(1).StartSketchPoint) sText = "Here is the last and final line of text." Set oTextBox = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(4, dYCoord), sText) ' Exit the sketch from the edit environment. oSketch.ExitEdit End Sub
When I run it, nearly every line states "Let" and "Set" are no longer supported... This is the only code I can find online as well. How can this be accomplished now in v2018? Thanks.
Solved! Go to Solution.