Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Change value of textbox

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
johan
421 Views, 5 Replies

Change value of textbox

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

 

 

5 REPLIES 5
Message 2 of 6
RodrigoEiras
in reply to: johan

 

 

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
Message 3 of 6
johan
in reply to: RodrigoEiras

Yes exactly! Thank you!

Message 4 of 6
johan
in reply to: RodrigoEiras

How do i access dimensions  (d1, d2 and so on...)  in that sketched symbol?

 

Message 5 of 6
RodrigoEiras
in reply to: johan

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

Message 6 of 6
johan
in reply to: RodrigoEiras

Yess! Thank you, my life just got a little bit better!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report