iLogic sketch text

iLogic sketch text

mk92
Collaborator Collaborator
1,252 Views
5 Replies
Message 1 of 6

iLogic sketch text

mk92
Collaborator
Collaborator

Hello,

 

i want to iterate through the text boxes in my sketch. Is this possible?

 

I tried this:

 

Dim oDoc As PartDocument
oDoc = ThisDoc.Document
 
Dim oSketch As PlanarSketch 
oSketch = oSketch.Item(3)
 
Dim oTextBox As TextBox
oTextBox = oSketch.TextBoxes

            For Each oTextBox In oSketch.Item(3)
				i = i+1
	   Next
0 Likes
Accepted solutions (2)
1,253 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
Accepted solution

Hello,

 

You can iterate the textbox with the following snippet code.

 

Dim oPartDoc As PartDocument
Dim oTextbox As TextBox
    Set oPartDoc = ThisApplication.ActiveDocument
Dim oCd As ComponentDefinition
Dim oSketch As PlanarSketch

For Each oCd In oPartDoc.ComponentDefinitions
    For Each oSketch In oCd.Sketches
        For Each oTextbox In oSketch.TextBoxes
            MsgBox oTextbox.Text 'For each textbox available in the sketch a message box will popup
        Next
    Next
    
Next

I you found this was helpful please accept this as solution / Press the Kudos button below Smiley Wink.

 

Cheers,

SK.

 

Message 3 of 6

mk92
Collaborator
Collaborator

Thank you for your reply.

 

If i use it in my rule i get an error:

 

Error on line 18: "TextBox" is ambiguous. Imported from the namespaces or types "Inventor, System.Windows.Forms".

 

If i try to Import the Windows forms the error still exists.

 

Any ideas?

0 Likes
Message 4 of 6

mk92
Collaborator
Collaborator
Accepted solution

Got it!

 

Dim oTextbox As Inventor.TextBox

 

Solves the error!

Message 5 of 6

Anonymous
Not applicable

I guess only 15 line are there in the code. I don't know how you got error in line 18 did you modified the code?

 

I got error in line 3 due to set method used in the code so I removed it.

 

It works fine for me. What version of inventor are you using?

 

Dim oPartDoc As PartDocument
Dim oTextbox As TextBox
    oPartDoc = ThisApplication.ActiveDocument
Dim oCd As ComponentDefinition
Dim oSketch As PlanarSketch

For Each oCd In oPartDoc.ComponentDefinitions
    For Each oSketch In oCd.Sketches
        For Each oTextbox In oSketch.TextBoxes
            MsgBox (oTextbox.Text) 'For each textbox available in the sketch a message box will popup
        Next
    Next
    
Next
0 Likes
Message 6 of 6

Anonymous
Not applicable

Please ignore my previous post.

 

Cheers,

SK.

0 Likes