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: 

ComponentGraphics API

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
NemKumar
577 Views, 3 Replies

ComponentGraphics API

Hi, 

 

I am under the impression that if I want to copy whole componentDefinition to graphics, I should use GraphicsNode.AddComponentGraphics API.

However, when I pass partDoc.ComponentDefinition or assemDoc.ComponentDefinition, it just gives INVALID_ARGS error.

There is no sample or much information regarding that.

 

How do I create componentGraphics.

 

Thanks,

3 REPLIES 3
Message 2 of 4
Vladimir.Ananyev
in reply to: NemKumar

Could you please look at the sample published by Philippe Leefsma on GitHub.  This sample is included into the Inventor API Training module #16 on the ClientGraphics.  Here is the link

https://github.com/ADN-DevTech/Inventor-Training-Material/blob/master/Module%2016%20-%20Client%20Gra...

See AdnClientGraphicsManager class.

Cheers,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 3 of 4
NemKumar
in reply to: Vladimir.Ananyev

Hi,

 

I saw the reference you gave me but I would like to have an small working example for the componentGraphics in c# or VB.  As I can't seem to figure out the reason for failure.

Message 4 of 4
Vladimir.Ananyev
in reply to: NemKumar

I think you get error because AddComponentGraphics fails when using ComponentDefinition from the same document :(.  Open an assembly document with at least one component and run the following demo code:

Sub ComponentGraphicsDemo()

    Dim oAsmDoc As AssemblyDocument
    Set oAsmDoc = ThisApplication.ActiveDocument
    Dim oAsmDef As AssemblyComponentDefinition
    Set oAsmDef = oAsmDoc.ComponentDefinition
    
    Dim oClientGraphics As ClientGraphics
    
    On Error Resume Next
    Set oClientGraphics = oAsmDef.ClientGraphicsCollection.Item("ADN")

    If Err.Number = 0 Then
        'delete client graphics collection
        On Error GoTo 0
        Call oClientGraphics.Delete
        ThisApplication.ActiveView.Update
        End
    Else
        Err.Clear
        On Error GoTo 0
        Set oClientGraphics = oAsmDef.ClientGraphicsCollection.Add("ADN")
        
        Dim oNode As GraphicsNode
        Set oNode = oClientGraphics.AddNode(1)
    
        Dim oOcc As ComponentOccurrence
        Set oOcc = oAsmDef.Occurrences.Item(1)
        Dim oDef As PartComponentDefinition
        Set oDef = oOcc.Definition
    
        Dim oComponentGraphics As ComponentGraphics
        Set oComponentGraphics = oNode.AddComponentGraphics(oDef)
        
        Dim oColor As color
        Set oColor = ThisApplication.TransientObjects.CreateColor(255, 0, 0)
        oColor.Opacity = 0.3

        oComponentGraphics.color = oColor
        
        ThisApplication.ActiveView.Update
    End If
    
    Beep
End Sub

Hope it could help.

Cheers,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

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

Post to forums  

Autodesk Design & Make Report