Ilogic - cant get view properties to populate into sketch symbol

Ilogic - cant get view properties to populate into sketch symbol

ahobby
Contributor Contributor
657 Views
3 Replies
Message 1 of 4

Ilogic - cant get view properties to populate into sketch symbol

ahobby
Contributor
Contributor

Trying to get a view information to populate the prompted fields of a sketch symbol. 

 

It works for selecting the view, but once I select the sketch label I want I get the following error:

 

Public member 'TextBoxes' on type 'SketchedSymbol' not found.

 

 

Any help would be highly appreciated... drawing file attached to laugh at.

 

SyntaxEditor Code Snippet

Dim doc as DrawingDocument
doc = ThisApplication.ActiveDocument

Dim oSymbol As SketchedSymbol
 
Dim oViewName As String

'choose the view we want to grab properties from   
Dim oObj As Object     
oObj = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter,"Select a view:")
 

    If oObj Is Nothing Then
        Else
        'get the view name
        Dim viewName As String = oObj.Name
        'send the view label name back to the public variable oViewName
        oViewName = viewName 
    End If


'change the result text of the selected SketchedSymbol

Dim oSS As SketchedSymbol

'choose the sketch symbol we want to inject text strings into fields of

'oSS=ThisApplication.CommandManager.Pick(SelectionFilterEnum.kSketchBlocksFilter,"Select a Label:")

oSS=ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingsketchedSymbolFilter,"Select a Label:")

'if our sketched symbol name is named ITEM8 then do the actions

    If oSS.Definition.Name = "ITEM8" Then
    
            Dim oEachText As TextBox
            
            Dim I
        
                For I = 1 To oSS.TextBoxes.Count
        
                oEachText = oSS.TextBoxes(I)
        
                    If (oEachText.Text = "NAME") Then
                    oNewResultText = oEachText
                    End If
                Next
        Else
    
        
    End If

          

        



   

   

 

 

 

0 Likes
Accepted solutions (2)
658 Views
3 Replies
Replies (3)
Message 2 of 4

JaneFan
Autodesk
Autodesk

Hello @ahobby

 

There is no TextBoxes member in SketchedSymbol object. Please try to replace oSS.TextBoxes with following one if SketchedSymbol is picked: 

oSS.Definition.Sketch.TextBoxes




Jane Fan
Inventor/Fusion QA Engineer
0 Likes
Message 3 of 4

dgreatice
Collaborator
Collaborator
Accepted solution

Hi,

 

see my attachment, try to add you own base view, then add my sketch symbols "MY ITEM".

 

try my example code:

 

Dim App As Application
App = ThisApplication

Dim oDV As DrawingView
oDV = App.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select View:")

Dim SktSymb As SketchedSymbol
Dim oTB As TextBox

For Each SktSymb In oDV.Parent.SketchedSymbols
If LCase(SktSymb.Name) = LCase("MY ITEM") Then
For Each oTB In SktSymb.Definition.Sketch.TextBoxes
If LCase(oTB.Text) = LCase("<TEXT>") Then
Call SktSymb.SetPromptResultText(oTB, "Hello World")
End If
Next
End If
Next

 

 

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
0 Likes
Message 4 of 4

ahobby
Contributor
Contributor
Accepted solution

@dgreatice

 

THANK YOU!

 

Your code snippet was just what I needed to fix it - I've been playing with this code for a week trying to get it to do what I wanted.

 

 

I tweaked it a little bit to not automatically hunt through each sketch symbol, but instead let the user select the symbol:

 

SyntaxEditor Code Snippet

Dim App As Application
App = ThisApplication

Dim oDV As DrawingView
oDV = App.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select View:")

Dim SktSymb As SketchedSymbol
Dim oTB As TextBox

'choose the sketch symbol we want to inject text strings into fields of
SktSymb=ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingsketchedSymbolFilter,"Select a Label:")

'if our sketched symbol name is named ITEM8 then do the actions'    If SktSymb.Definition.Name = "ITEM8" Then'For Each SktSymb In oDV.Parent.SketchedSymbols
    If LCase(SktSymb.Name) = LCase("ITEM8") Then
        For Each oTB In SktSymb.Definition.Sketch.TextBoxes
            If LCase(oTB.Text) = LCase("NAME") Then
                Call SktSymb.SetPromptResultText(oTB, oDV.Name)
            End If
        Next
    End If
'Next

 

0 Likes