Getting SurfaceGraphics ID throws an error

Getting SurfaceGraphics ID throws an error

dylanTEV9W
Advocate Advocate
207 Views
0 Replies
Message 1 of 1

Getting SurfaceGraphics ID throws an error

dylanTEV9W
Advocate
Advocate

Pretty simple code for some reason the surface graphics object is throwing an error whenever I try to retrieve an ID from it. 

*This code needs a single part document open at runtime to work. 

void Test()
{
PartDocument part_doc = (PartDocument)inventor_application.ActiveDocument;

ClientGraphicsCollection graphics_collection = part_doc.ComponentDefinition.ClientGraphicsCollection;

ClientGraphics client_graphics = graphics_collection.Add("Test123");

GraphicsNode handle_node = client_graphics.AddNode(1);

Point point = inventor_application.TransientGeometry.CreatePoint(0, 0, 0);

SurfaceBody sphere = inventor_application.TransientBRep.CreateSolidSphere(point, 1);

handle_node.Selectable = true;

SurfaceGraphics handle_graphics = handle_node.AddSurfaceGraphics(sphere);

handle_graphics.ChildrenAreSelectable = true;

handle_graphics.DisplayedFaces[1].Selectable = true;

handle_graphics.DisplaySilhouettes = true;

inventor_application.ActiveView.Update();

int id = handle_graphics.Id; //this line here throws an error 

Debug.Print(id.ToString());
}

 

if I replace the last two lines with "Debug.Print(handle_graphics.Id.ToString()); " then I get the same error. If anyone can help me fix this I would greatly appreciate it!

0 Likes
208 Views
0 Replies
Replies (0)