Ability to display a "direction" arrow using the API.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
I'm working through a problem and wanted to check I hadn't missed something obvious within the API.
When working with the built-in tools manually, you are occasionally presented with a "direction" arrow within the UI:
These are client graphics I believe and I have found the following article useful:
But I have an issue and that is that I need to create a version of the arrow that can be flipped about a selected axis.
Is there something I am missing within the API that can do this for me or is it a manual task of creating/recreating the transient geometry as required?
here is a c# method I have cobbled together that takes several inputs I thought may be needed:
public class ClientGFX { private static readonly ILog log = LogManager.GetLogger(typeof(Parameters)); public static void ClientGraphics3DPrimitives(string clientGraphicsCollectionId, Application InventorApp, PartComponentDefinition compDef, Point origin, Point end, Line centreline, UnitVector arrowDirection) { try { Document oDoc = InventorApp.ActiveDocument; // Set a reference to component definition of the active document. // This assumes that a part or assembly document is active PartComponentDefinition oCompDef = compDef; // Check to see if the test graphics data object already exists. // If it does clean up by removing all associated of the client // graphics from the document. If it doesn't create it ClientGraphics oClientGraphics = null; try { oClientGraphics = oCompDef.ClientGraphicsCollection[clientGraphicsCollectionId]; } catch (Exception ex) { // An existing client graphics object was successfully // obtained so clean up oClientGraphics.Delete(); // Update the display to see the results InventorApp.ActiveView.Update(); log.Debug(ex.Message, ex); } finally { TransientGeometry oTransGeom = InventorApp.TransientGeometry; // Create the ClientGraphics object. if (oClientGraphics == null) { oClientGraphics = oCompDef.ClientGraphicsCollection.Add(clientGraphicsCollectionId); } // Create a new graphics node within the client graphics objects GraphicsNode oSurfacesNode = oClientGraphics.AddNode(1); TransientBRep oTransientBRep = InventorApp.TransientBRep; // Create a point representing the center of the bottom of // the cone Point coneBottom = origin; //Point coneBottom = InventorApp.TransientGeometry.CreatePoint(0, 0, 0); // Create a point representing the tip of the cone //Point oTop = end; Point coneTop = InventorApp.TransientGeometry.CreatePoint(0, 10, 0); // Create a point representing the base of the cylinder Point cylinderBottom = InventorApp.TransientGeometry.CreatePoint(0, -40, 0); //sort out the direction we need to point. Matrix conePos = InventorApp.TransientGeometry.CreateMatrix(); Vector conePosVector = InventorApp.TransientGeometry.CreateVector(arrowDirection.X, arrowDirection.Y, arrowDirection.Z); conePos.SetTranslation(conePosVector); conePos.SetToRotateTo(coneTop.VectorTo(coneBottom), conePosVector); //move the necessary points coneTop.TransformBy(conePos); cylinderBottom.TransformBy(conePos); // Create a transient cone body //SurfaceBody oBody = oTransientBRep.CreateSolidCylinderCone(oBottom, oTop, 5, 5, 0); SurfaceBody oBody = oTransientBRep.CreateSolidCylinderCone(coneBottom, coneTop, 5, 5, 0); // Reset the top point indicating the center of the top of // the cylinder //oTop = InventorApp.TransientGeometry.CreatePoint(0, -40, 0); coneTop = InventorApp.TransientGeometry.CreatePoint(0, -40, 0); // Create a transient cylinder body //SurfaceBody oCylBody = oTransientBRep.CreateSolidCylinderCone(oBottom, oTop, 2.5, 2.5, 2.5); SurfaceBody oCylBody = oTransientBRep.CreateSolidCylinderCone(coneBottom, cylinderBottom, 2.5, 2.5, 2.5); // Union the cone and cylinder bodies oTransientBRep.DoBoolean(oBody, oCylBody, BooleanTypeEnum.kBooleanTypeUnion); // Create client graphics based on the transient body SurfaceGraphics oSurfaceGraphics = oSurfacesNode.AddSurfaceGraphics(oBody); // Update the view to see the resulting curves InventorApp.ActiveView.Update(); } } catch (Exception ex) { log.Error(ex.Message, ex); } } }
I think perhaps I have misunderstood the Matrix translation required in this instance.
Any pointers will be gratefully received!
Thanks,
Alex.
Alex Fielder
Inventor Expert
https://github.com/alexfielder/
LinkedIn - Github Inventor Extension Server - Bonkers polygon iLogic thing
Top ten iLogic Tips - API Shortcut In Google Chrome - Assembly Extrusion Example