void DoDemo() { Inventor.Application InvApp = AdnInventorUtilities.InvApplication; _interactionManager = new AdnInteractionManager(InvApp); _interactionManager.Initialize(); _interactionManager.SelectEvents.SingleSelectEnabled = true; _interactionManager.OnTerminateEvent += new AdnInteractionManager.OnTerminateHandler(OnTerminateEvent); _interactionManager.SelectEvents.OnSelect += new SelectEventsSink_OnSelectEventHandler(SelectEvents_OnSelect); _interactionManager.AddSelectionFilter(SelectionFilterEnum.kPartFacePlanarFilter); _interactionManager.AddSelectionFilter(SelectionFilterEnum.kWorkPlaneFilter); _interactionManager.Start("Select workplane/planar face: "); _clientGraphicsMng = new AdnClientGraphicsManager( AdnInventorUtilities.InvApplication, AdnInventorUtilities.AddInGuid); _clientGraphicsMng.SetGraphicsSource( _interactionManager.InteractionEvents); _curveGraph = null; _mode = SelectModeEnum.kPlaneSelect; }
void DoDemo() { Inventor.Application InvApp = AdnInventorUtilities.InvApplication; _interactionManager = new AdnInteractionManager(InvApp); _interactionManager.Initialize(); _interactionManager.OnTerminateEvent += new AdnInteractionManager.OnTerminateHandler(OnTerminateEvent); _interactionManager.MouseEvents.OnMouseDown += new MouseEventsSink_OnMouseDownEventHandler(MouseEvents_OnMouseDown); _interactionManager.Start("Click points anywhere in model window: "); _clientGraphicsMng = new AdnClientGraphicsManager( AdnInventorUtilities.InvApplication, AdnInventorUtilities.AddInGuid); _clientGraphicsMng.SetGraphicsSource( _interactionManager.InteractionEvents); _lineStripGraph = null; }
void DoDemo() { Inventor.Application InvApp = AdnInventorUtilities.InvApplication; _compDef = AdnInventorUtilities.GetCompDefinition(InvApp.ActiveDocument); _surfaceBodies = AdnInventorUtilities.GetTransientBodies(_compDef); _interactionManager = new AdnInteractionManager(InvApp); _interactionManager.Initialize(); _interactionManager.OnTerminateEvent += new AdnInteractionManager.OnTerminateHandler(OnTerminateEvent); _clientGraphicsMng = new AdnClientGraphicsManager( InvApp, AdnInventorUtilities.AddInGuid); _clientGraphicsMng.SetGraphicsSource(_interactionManager.InteractionEvents); _interactionManager.SelectEvents.SingleSelectEnabled = true; _interactionManager.AddSelectionFilter(SelectionFilterEnum.kPartFacePlanarFilter); _interactionManager.AddSelectionFilter(SelectionFilterEnum.kWorkPlaneFilter); _interactionManager.SelectEvents.OnSelect += new SelectEventsSink_OnSelectEventHandler(SelectEvents_OnSelect); _interactionManager.Start("Select planar face or workplane: "); }
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); }
///////////////////////////////////////////////////////////// // Use: OnPreSelect Handler. // ///////////////////////////////////////////////////////////// private void SelectEvents_OnPreSelect( ref object PreSelectEntity, out bool DoHighlight, ref ObjectCollection MorePreSelectEntities, SelectionDeviceEnum SelectionDevice, Point ModelPosition, Point2d ViewPosition, View View) { if (_PreSelectFilters.Count != 0 && !_PreSelectFilters.Contains( AdnInteractionManager.GetInventorType(PreSelectEntity))) { DoHighlight = false; return; } DoHighlight = true; }
void DoDemo() { Inventor.Application InvApp = AdnInventorUtilities.InvApplication; _interactionManager = new AdnInteractionManager(InvApp); _interactionManager.Initialize(); _interactionManager.OnTerminateEvent += new AdnInteractionManager.OnTerminateHandler(OnTerminateEvent); _interactionManager.MouseEvents.OnMouseDown += new MouseEventsSink_OnMouseDownEventHandler(MouseEvents_OnMouseDown); _interactionManager.Start("Select Start Point: "); _clientGraphicsMng = new AdnClientGraphicsManager( AdnInventorUtilities.InvApplication, AdnInventorUtilities.AddInGuid); _clientGraphicsMng.SetGraphicsSource( _interactionManager.InteractionEvents); }
////////////////////////////////////////////////////////////////////////////////////////////// // Trigger final view update when Interaction is terminated // ////////////////////////////////////////////////////////////////////////////////////////////// void OnTerminateEvent(object o, AdnInteractionManager.OnTerminateEventArgs e) { _clientGraphicsMng.UpdateView(); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ClientGraphics simulation running within InteractionEvents using overlay or preview graphics // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void RunWithInteraction(bool overlay) { Initialize(); System.Windows.Forms.Application.AddMessageFilter(new MsgFilter()); Inventor.Application InvApp = AdnInventorUtilities.InvApplication; AssemblyDocument doc = InvApp.ActiveDocument as AssemblyDocument; AssemblyComponentDefinition compDef = doc.ComponentDefinition; Inventor.View view = InvApp.ActiveView; Matrix matrix = InvApp.TransientGeometry.CreateMatrix(); AdnInteractionManager interactionManager = new AdnInteractionManager(InvApp); interactionManager.Initialize(); AdnClientGraphicsManager clientGraphicsMng = new AdnClientGraphicsManager( InvApp, AdnInventorUtilities.AddInGuid); clientGraphicsMng.InteractionGraphicsMode = (overlay ? AdnInteractionGraphicsModeEnum.kOverlayGraphics : AdnInteractionGraphicsModeEnum.kPreviewGraphics); foreach (ComponentOccurrence occurrence in compDef.Occurrences) { occurrence.Visible = false; } interactionManager.Start("Simulation with InteractionEvents"); clientGraphicsMng.SetGraphicsSource(interactionManager.InteractionEvents); List<GraphicsNode> nodes = new List<GraphicsNode>(); foreach (ComponentOccurrence occurrence in compDef.Occurrences) { SurfaceBody body = occurrence.Definition.SurfaceBodies[1]; SurfaceGraphics surfGraph = clientGraphicsMng.DrawSurface(body, null); GraphicsNode node = surfGraph.Parent; if (occurrence.RenderStyle != null) node.RenderStyle = occurrence.RenderStyle; nodes.Add(node); } AdnTimer timer = new AdnTimer(); double[] transfo = new double[16]; _bActive = true; while (_bActive) { System.Windows.Forms.Application.DoEvents(); double dT = timer.ElapsedSeconds; _dynamicsWorld.StepSimulation(dT, 10); int idx = 0; foreach (RigidBody body in _mapOccurrencesToBodies.Values) { body.GetWorldTransform(ref transfo); matrix.PutMatrixData(ref transfo); nodes[idx].Transformation = matrix; ++idx; } clientGraphicsMng.UpdateView(); ComputeFrameRate(dT); } _dynamicsWorld.CleanUp(); interactionManager.Stop(); foreach (ComponentOccurrence occurrence in compDef.Occurrences) { occurrence.Visible = true; } }
////////////////////////////////////////////////////////////////////////////////////////////// // Trigger final view update when Interaction is terminated // ////////////////////////////////////////////////////////////////////////////////////////////// void OnTerminateEvent(object o, AdnInteractionManager.OnTerminateEventArgs e) { _clientGraphicsMng.UpdateView(); _componentDocument.Close(true); }
////////////////////////////////////////////////////////////////////////////////////////////// // Starts dimension command // ////////////////////////////////////////////////////////////////////////////////////////////// void StartCommand() { Inventor.Application InvApp = AdnInventorUtilities.InvApplication; _Tg = InvApp.TransientGeometry; _TBrep = InvApp.TransientBRep; _interactionManager = new AdnInteractionManager(InvApp); _interactionManager.Initialize(); _interactionManager.OnTerminateEvent += new AdnInteractionManager.OnTerminateHandler(OnTerminateEvent); _interactionManager.AddPreSelectionFilter(ObjectTypeEnum.kVertexObject); _interactionManager.AddPreSelectionFilter(ObjectTypeEnum.kVertexProxyObject); _interactionManager.AddPreSelectionFilter(ObjectTypeEnum.kWorkPointObject); _interactionManager.AddPreSelectionFilter(ObjectTypeEnum.kWorkPointProxyObject); _interactionManager.SelectEvents.SingleSelectEnabled = true; _interactionManager.SelectEvents.OnSelect += new SelectEventsSink_OnSelectEventHandler(SelectEvents_OnSelect); _interactionManager.Start("Select dimension first point: "); _clientGraphicsMng = new AdnClientGraphicsManager( AdnInventorUtilities.InvApplication, AdnInventorUtilities.AddInGuid); _clientGraphicsMng.SetGraphicsSource( _interactionManager.InteractionEvents); }
////////////////////////////////////////////////////////////////////////////////////////////// // Trigger final view update when Interaction is terminated // ////////////////////////////////////////////////////////////////////////////////////////////// void OnTerminateEvent(object o, AdnInteractionManager.OnTerminateEventArgs e) { SetModelVisibility(true); _clientGraphicsMng.UpdateView(); }
void DoDemo() { Inventor.Application InvApp = AdnInventorUtilities.InvApplication; if (InvApp.ActiveDocument == null || !(InvApp.ActiveDocument is DrawingDocument)) { System.Windows.Forms.MessageBox.Show( "A Drawing Document must be active...", "Invalid Document Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); return; } _Tg = InvApp.TransientGeometry; _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 Symbol: "); _clientGraphicsMng = new AdnClientGraphicsManager( AdnInventorUtilities.InvApplication, AdnInventorUtilities.AddInGuid); _clientGraphicsMng.Transacting = true; _clientGraphicsMng.SetGraphicsSource( _interactionManager.InteractionEvents); _symbolNode = null; DrawingDocument document = InvApp.ActiveDocument as DrawingDocument; _sheet = document.ActiveSheet; _symbolNode = null; }