////////////////////////////////////////////////////////////////////////////////////////////// // Insert Component as ComponentGraphics // ////////////////////////////////////////////////////////////////////////////////////////////// void InsertAsComponentGraphics(Matrix transfo) { Inventor.Application InvApp = AdnInventorUtilities.InvApplication; _clientGraphicsMng.SetGraphicsSource(InvApp.ActiveDocument); ComponentDefinition compDef = AdnInventorUtilities.GetCompDefinition(_componentDocument); _compGraph = _clientGraphicsMng.DrawComponent(compDef); _compGraph.Parent.Transformation = transfo; _compGraph.Parent.Selectable = true; }
void DoDemo() { Inventor.Application InvApp = AdnInventorUtilities.InvApplication; string filename = AdnInventorUtilities.ShowOpenDialog( "Select Inventor file", "Inventor Files (*.ipt; *.iam)|*.ipt;*.iam"); if (filename == string.Empty) { return; } _componentDocument = InvApp.Documents.Open(filename, false); ComponentDefinition compDef = AdnInventorUtilities.GetCompDefinition(_componentDocument); _interactionManager = new AdnInteractionManager(InvApp); _interactionManager.Initialize(); _interactionManager.OnTerminateEvent += new AdnInteractionManager.OnTerminateHandler(OnTerminateEvent); _interactionManager.MouseEvents.MouseMoveEnabled = true; _interactionManager.MouseEvents.OnMouseDown += new MouseEventsSink_OnMouseDownEventHandler(MouseEvents_OnMouseDown); _interactionManager.MouseEvents.OnMouseMove += new MouseEventsSink_OnMouseMoveEventHandler(MouseEvents_OnMouseMove); _interactionManager.Start("Place Component: "); _clientGraphicsMng = new AdnClientGraphicsManager( AdnInventorUtilities.InvApplication, AdnInventorUtilities.AddInGuid); _clientGraphicsMng.SetGraphicsSource( _interactionManager.InteractionEvents); _compGraph = _clientGraphicsMng.DrawComponent(compDef); }
////////////////////////////////////////////////////////////////////////////////////////////// // // ////////////////////////////////////////////////////////////////////////////////////////////// void MouseEvents_OnMouseDown( MouseButtonEnum Button, ShiftStateEnum ShiftKeys, Inventor.Point ModelPosition, Point2d ViewPosition, Inventor.View View) { if (Button != MouseButtonEnum.kLeftMouseButton) { return; } InsertAsSurfaceGraphics(_compGraph.Parent.Transformation); _clientGraphicsMng.SetGraphicsSource( _interactionManager.InteractionEvents); ComponentDefinition compDef = AdnInventorUtilities.GetCompDefinition(_componentDocument); _compGraph = _clientGraphicsMng.DrawComponent(compDef); }
public ComponentGraphics DrawComponent( ComponentDefinition compDef, GraphicsNode node) { try { AdnGraphics graphicsData = WorkingGraphics; if (node == null) { node = graphicsData.ClientGraphics.AddNode( graphicsData.GetGraphicNodeFreeId()); } ComponentGraphics graphic = node.AddComponentGraphics(compDef); return(graphic); } catch { return(null); } }
void DoDemo() { Inventor.Application InvApp = AdnInventorUtilities.InvApplication; string filename = AdnInventorUtilities.ShowOpenDialog( "Select Inventor file", "Inventor Files (*.ipt; *.iam)|*.ipt;*.iam"); if (filename == string.Empty) return; _componentDocument = InvApp.Documents.Open(filename, false); ComponentDefinition compDef = AdnInventorUtilities.GetCompDefinition(_componentDocument); _interactionManager = new AdnInteractionManager(InvApp); _interactionManager.Initialize(); _interactionManager.OnTerminateEvent += new AdnInteractionManager.OnTerminateHandler(OnTerminateEvent); _interactionManager.MouseEvents.MouseMoveEnabled = true; _interactionManager.MouseEvents.OnMouseDown += new MouseEventsSink_OnMouseDownEventHandler(MouseEvents_OnMouseDown); _interactionManager.MouseEvents.OnMouseMove += new MouseEventsSink_OnMouseMoveEventHandler(MouseEvents_OnMouseMove); _interactionManager.Start("Place Component: "); _clientGraphicsMng = new AdnClientGraphicsManager( AdnInventorUtilities.InvApplication, AdnInventorUtilities.AddInGuid); _clientGraphicsMng.SetGraphicsSource( _interactionManager.InteractionEvents); _compGraph = _clientGraphicsMng.DrawComponent(compDef); }
////////////////////////////////////////////////////////////////////////////////////////////// // // ////////////////////////////////////////////////////////////////////////////////////////////// void MouseEvents_OnMouseDown( MouseButtonEnum Button, ShiftStateEnum ShiftKeys, Inventor.Point ModelPosition, Point2d ViewPosition, Inventor.View View) { if (Button != MouseButtonEnum.kLeftMouseButton) return; InsertAsSurfaceGraphics(_compGraph.Parent.Transformation); _clientGraphicsMng.SetGraphicsSource( _interactionManager.InteractionEvents); ComponentDefinition compDef = AdnInventorUtilities.GetCompDefinition(_componentDocument); _compGraph = _clientGraphicsMng.DrawComponent(compDef); }