SurfaceTextureSymbol insert via Copy & Paste

SurfaceTextureSymbol insert via Copy & Paste

weiser
Advocate Advocate
312 Views
0 Replies
Message 1 of 1

SurfaceTextureSymbol insert via Copy & Paste

weiser
Advocate
Advocate

Hi,

we are using onls a few different symbols for surface texture, so I would like to make it more comfortable for the user to insert the symbols.

My idea is the following workflow:

  • via a buttton in the ribbon-menu a form with the availible symbols for surface texture opens up and stays until it's closed by the user
  • when pressing a button "insert symbol" in the form the selected symbol is created as a template and it's been placed on the actual sheet in a "region of no interest"
  • the template-symbol is been selected automatically and it's been copied to clipboard via CommandManager.ControlDefinition("AppCopyCmd")
  • because inserting a copied symbol while anything is selected, the actual SelectionSet is been cleared.
  • by using the CommandManager.ControlDefinition("AppPasteCmd") the process of inserting is being started (when using it manually the user can now choose the entity to connect the symbol to)
  • finally the template is been removed from the sheet

I've tried a similar process in another way, but I like to know, if this way could be done also, because it seems to be quite simple to implement ;-). Thanks @JelteDeJong for his solution!

Add surface-finish to ExtensionLine by picking interactive from drawing 

 

So, that's the plan .... and here is the code I've been written for that (just the process of insert dummy and try to start the copy & paste-process) ... But nothing happens at all, besides that the template is created.

 

Would be great if you share you thoughts an help me along with this.

 

 

    Public Sub InsertSurfaceFinishByCopyAndPaste()

        ' check, if active document is a drawing
        If Not ThisApplication.ActiveDocument.DocumentType = Inventor.DocumentTypeEnum.kDrawingDocumentObject _
        Then
            MsgBox ("Funktion kann nur in einer Zeichnung verwendet werden.")
            Exit Sub
        End If

        ' Dimensionierung und Setzen der benötigten Variablen
        Dim oDrawDoc As DrawingDocument
        Set oDrawDoc = ThisApplication.ActiveDocument
        Dim oSheet As Sheet
        Set oSheet = oDrawDoc.ActiveSheet
        Dim oTG As TransientGeometry
        Set oTG = ThisApplication.TransientGeometry
        Dim oLeaderPoints As Inventor.ObjectCollection
        Set oLeaderPoints = ThisApplication.TransientObjects.CreateObjectCollection
        Dim oSurfaceSymbol As SurfaceTextureSymbol
        Dim oSymbol As SurfaceTextureSymbol
        Dim SymbolIndex As Integer
        SymbolIndex = oSheet.SurfaceTextureSymbols.Count + 1

        ' Erzeugen eines Dummy-Symbols
        oLeaderPoints.Clear
        Call oLeaderPoints.Add(oTG.CreatePoint2d(0.1, 0.1))
        Set oSymbol = oSheet.SurfaceTextureSymbols.Add(oLeaderPoints)
        oSymbol.AllAroundSymbol = True

        ' select the template-symbol
        Dim oSelectSet As SelectSet
        Set oSelectSet = ThisApplication.ActiveDocument.SelectSet
        Call oSelectSet.Clear
        Call oSelectSet.Select(oSymbol)
                
         ' Execute the COPY command.
         Dim oCopyControlDef As ControlDefinition
         Set oCopyControlDef = ThisApplication.CommandManager.ControlDefinitions.Item("AppCopyCmd")
         Call oCopyControlDef.Execute
     
         Call oSelectSet.Clear
         Call oSelectSet.Select(oSheet) ' this works in the interactive process very well

         ' Execute the PASTE command.
         Dim oPasteControlDef As ControlDefinition
         Set oPasteControlDef = ThisApplication.CommandManager.ControlDefinitions.Item("AppPasteCmd")
         Call oPasteControlDef.Execute

         ' delete the dummy-symbol
         ' .....

    End Sub

 

 

0 Likes
313 Views
0 Replies
Replies (0)