how do i change the value of a sketched symbol containing a textbox with text?
I cant find anything that works.
I insert a textbox called "TheName" and in "TheName" there is a textbox with text i want to change.
I know how to get the sketched symol into the drawing but not how to set the text of the textbox
Solved! Go to Solution.
Solved by RodrigoEiras. Go to Solution.
Solved by RodrigoEiras. Go to Solution.
This piece of code would allow you to go throught the symbols definition in your drawing, locate one of them and access the text boxes on it.
I hope this is what you were asking for.
SyntaxEditor Code Snippet
Dim oDrawingDoc=ThisDrawing.Document Dim oSketchedSymbolDef As SketchedSymbolDefinition Dim oSketch As Sketch For Each oSketchedSymbolDef In oDrawingDoc.SketchedSymbolDefinitions MessageBox.Show("Symbol Name=" & oSketchedSymbolDef.Name , "Debugging") If oSketchedSymbolDef.Name="TestSymbol" Then oSketchedSymbolDef.Edit(oSketch) For Each oTextBox In oSketch.TextBoxes MessageBox.Show("Test Box Text=" & oTextBox.Text , "Debugging") Next oSketchedSymbolDef.ExitEdit(True) Else 'Do nothing End If Next
How do i access dimensions (d1, d2 and so on...) in that sketched symbol?
Hi Johan,
You can go through the dimensions in the sketch with a loop like this one:
Be careful!. Values for parameters must be informed in Inventor internal units (cm for distances and radians for angles)
Dim oDrawingDoc=ThisDrawing.Document
Dim oSketchedSymbolDef As SketchedSymbolDefinition
Dim oSketch As Sketch
Dim oDimConstraint As DimensionConstraint
For Each oSketchedSymbolDef In oDrawingDoc.SketchedSymbolDefinitions
MessageBox.Show("Symbol Name=" & oSketchedSymbolDef.Name , "Debugging")
If oSketchedSymbolDef.Name="TestSymbol" Then
'Look for text boxes
oSketchedSymbolDef.Edit(oSketch)
For Each oTextBox In oSketch.TextBoxes
MessageBox.Show("Test Box Text=" & oTextBox.Text , "Debugging")
Next
'Look for dimensions
For Each oDimConstraint In oSketch.DimensionConstraints
paramX = oDimConstraint.Parameter
Select Case paramX.Name
Case "d1"
paramX.Value = 'new value
Case "d2"
paramX.Value = 'new value
Case "d3"
paramX.Value = 'new value
Case Else
End Select
Next
oSketchedSymbolDef.ExitEdit(True)
Else
'Do nothing
End If
Next