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,
Solved! Go to Solution.
Solved by Vladimir.Ananyev. Go to Solution.
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
See AdnClientGraphicsManager class.
Cheers,
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.
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,
Can't find what you're looking for? Ask the community or share your knowledge.