Auto number sketched symbols

Auto number sketched symbols

danmachen
Advocate Advocate
682 Views
3 Replies
Message 1 of 4

Auto number sketched symbols

danmachen
Advocate
Advocate

I am looking for an iLogic code that will allow users to select multiple sketched symbols and automatically number them and insert as a text box into the drawing.

 

This is the ideal:

stamp selection.PNG

auto note.PNG

 

 

e.g.The predefined sketched symbols are contained in a separate drawing file (which is within the shared sketched symbol library:

 

"\Inventor Data (MAC)\Design_Data\Symbol Library\General Symbols.idw"

 I found a code snippet here that allows the single insertion of a sketched symbol but not multiple at once and without any automatic numbering.

 

 

    Sub Main()
        'Query stamp insertion requirement
        oDrawDoc = ThisDoc.Document
        question = MessageBox.Show("Do you want to insert a stamp?", "Stamp Requirement", MessageBoxButtons.YesNo, MessageBoxIcon.Question)

        If question = vbYes Then
            Dim strSelectedStamp As String = "Result2"
            Dim strStampList As New ArrayList
            strStampRequired = True
            'strStampList.Add("F&C Stamp Round")
            'strStampList.Add("As-Built Stamp Round")
            'strStampList.Add("Test")
            'strSelectedStamp = InputListBox("Please select a stamp.", strStampList, strSelectedStamp, "Stamp Selection", "Available Stamps")
            Dim strDrawDoc As Inventor.DrawingDocument = ThisApplication.ActiveDocument
            
            Dim SourceFile1 As String = "\\vpfs1\Inventor Data (MAC)\Design_Data\Symbol Library\General Symbols.idw"
       
            
            Dim strSourceIDW As DrawingDocument
            strSourceIDW = ThisApplication.Documents.Open(SourceFile1, False)
            Dim symbolDef As SketchedSymbolDefinition

            For Each symbolDef In strSourceIDW.SketchedSymbolDefinitions
                strStampList.Add(symbolDef.Name)
            Next
            
            strSelectedStamp = InputListBox("Please select a stamp.", strStampList, strSelectedStamp, "Stamp Selection", "Available Stamps")
            For Each symbolDef In strSourceIDW.SketchedSymbolDefinitions
                If (StrComp(symbolDef.Name, strSelectedStamp, vbTextCompare) = 0) Then
                    CopyFrom = symbolDef.CopyTo(strDrawDoc, True)

                    If MsgBox("Would you like to place the stamp on the drawing?", MsgBoxStyle.YesNo, "Insert Stamp") = MsgBoxResult.Yes Then
                        'Insert stamp if required
                        'InsertSymbol(symbolDef.Name)
                
                    
            Dim oSketchedSymbolDef As SketchedSymbolDefinition _
            = oDrawDoc.SketchedSymbolDefinitions.Item(strSelectedStamp)
            Dim oSheet As Sheet = oDrawDoc.ActiveSheet
            'create insertion point, coordinates - in cm !
            Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
                Dim oInsertionPoint As Point2d = oTG.CreatePoint2d(10, 10)
                ' Add an instance of the sketched symbol definition to the sheet.
                ' Rotate angle = 0 radians,
                    ' scale = 1 when adding
                ' no prompt text
            
                Dim oSketchedSymbol As SketchedSymbol _
                = oSheet.SketchedSymbols.Add( _
                oSketchedSymbolDef, _
                oInsertionPoint, _
                0, 1, Nothing)
                                                
                    End If
                
                End If
            Next
            strSourceIDW.Close()
                

        End If

    End Sub




    

 

Any help?

 

 

Dan Machen
Autodesk Inventor 2019 Certified Professional
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

Ideas that need support:
Circular / Rectangular Point Matrix
Allow Axis & Plane Selection on Rectangular / Circular pattern
Graphical iLogic Programming
0 Likes
683 Views
3 Replies
Replies (3)
Message 2 of 4

matt_jlt
Collaborator
Collaborator

Hi Dan, I'm a bit confused on the question. You said you were trying to add multiple sketched symbols onto a drawing but into a text box? Are the sketch symbols just text or are they actual shapes etc.

What is looks like to me is that you have a bunch of sketch symbols that are just text notes stored in a drawing file acting as a library.

You want to run the ilogic rule and have a list of your notes to select from. When you select the items you want it will add them to a text box on the drawing and automatically assign each note a number.

 

If i am anywhere near the mark and there is only text notes, I would think a simple text file would be much easier to maintain. If it is more than just notes then it won't work as you can't add them to a text box as you stated.

 

Let me know if you need any help or if I am in the ballpark of what you were thinking.

 

Matt.

0 Likes
Message 3 of 4

danmachen
Advocate
Advocate

Hi there,

 

Thank you for your response. That's exactly right as you say!

 

Thats right they are predefined text boxes and only contain text, we just want a method to combine them into one text box by picking multiples of them and automatically number them in order.

 

Any suggestions welcomed..

 

Dan Machen
Autodesk Inventor 2019 Certified Professional
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

Ideas that need support:
Circular / Rectangular Point Matrix
Allow Axis & Plane Selection on Rectangular / Circular pattern
Graphical iLogic Programming
0 Likes
Message 4 of 4

chandra.shekar.g
Autodesk Support
Autodesk Support

Hi @danmachen,

 

Currently, multiple selection is not supported in iLogic. But, a listbox from VBA form will support multiple selection. VBA code is given for a VBA form and Autonumber is also performing.

 

Here, instead of adding sketched symbol. A general note is used to add text. Before executing following code, a DrawingDocument should be opened.

 

Private Sub CommandButton1_Click()

    Dim oDoc As DrawingDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oSheet As Sheet
    Set oSheet = oDoc.ActiveSheet
    
    Dim oPt As Point2d
    Set oPt = ThisApplication.TransientGeometry.CreatePoint2d(10, 10)
    
    Dim Msg As String
    Dim i As Integer
    Dim j As Integer
    j = 0
    If ListBox1.ListIndex = -1 Then
        Msg = "Nothing"
    Else
        Msg = ""
        For i = 0 To ListBox1.ListCount - 1
            If ListBox1.Selected(i) Then
              j = j + 1
              Msg = Msg & ListBox1.List(i) & " " & j & vbCrLf
            End If
        Next i
    End If
    
    Dim oNote As GeneralNote
    Set oNote = oSheet.DrawingNotes.GeneralNotes.AddFitted(oPt, Msg)
    
End Sub

Private Sub UserForm_Initialize()
    With ListBox1
        .AddItem " F&C Stamp Round"
        .AddItem "As-Built Stamp Round"
        .AddItem "Test"
    End With
  
  ListBox1.MultiSelect = fmMultiSelectMulti
  
End Sub

Following video link explains how to add VBA form in Inventor.

 

https://www.youtube.com/watch?v=Sr0MvjeEFJU

 

VBA form can be called in indirectly by iLogic. Initially, a VBA form is called in a VBA module. Then, VBA module can be called by the following iLogic code.

 

VBA Module:

 

Public Sub Test1()

    Call UserForm1.Show

End Sub

iLogic code:

 

InventorVb.RunMacro("ApplicationProject", "Module1", "Test1")

Please feel free to contact if there is any queries.

 

If solves problem, click on "Accept  as solution" / give a "Kudo".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes