Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        //////////////////////////////////////////////////////////////////////////////////////////////
        // 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);
        }
Esempio n. 3
0
        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;

            _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;

            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;
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        private void StartCommand()
        {
            if (_frm != null)
            {
                if (!_frm.Visible)
                {
                    _frm.Dispose();
                }

                _frm.Focus();
                return;
            }

            RuleNameForm ruleNameForm = new RuleNameForm();

            System.Windows.Forms.DialogResult res =
                ruleNameForm.ShowModal();

            if (res != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            ruleNameForm.Dispose();

            _frm             = new LinkParametersForm(ruleNameForm.RuleName);
            _frm.Command     = this;
            _frm.FormClosed += new System.Windows.Forms.FormClosedEventHandler(Handle_Form_FormClosed);

            _frm.Show(new WinUtilities((IntPtr)AdnInventorUtilities.InvApplication.MainFrameHWND));

            if (_frm.TopMost == false)
            {
                _frm.BringToFront();
                _frm.Activate();
            }

            _InteractionManager = new AdnInteractionManager(AdnInventorUtilities.InvApplication);

            _InteractionManager.Initialize();

            _InteractionManager.SelectEvents.OnSelect +=
                new Inventor.SelectEventsSink_OnSelectEventHandler(SelectEvents_OnSelect);
        }
Esempio n. 8
0
        public static void Demo()
        {
            Inventor.Application InvApp = AdnInventorUtilities.InventorApplication;

            _interactionManager = new AdnInteractionManager(InvApp);

            _interactionManager.Initialize();

            _interactionManager.AddPreSelectionFilter(ObjectTypeEnum.kVertexObject);

            _interactionManager.SelectEvents.OnSelect += 
                new SelectEventsSink_OnSelectEventHandler(SelectEvents_OnSelect);

            _interactionManager.DoSelect("Select vertex: ");

            _clientGraphicsMng = new AdnClientGraphicsManager(
                AdnInventorUtilities.InventorApplication,
                AdnInventorUtilities.AddInGuid);

            _clientGraphicsMng.SetGraphicsSource(
                _interactionManager.InteractionEvents);
        }
Esempio n. 9
0
        public static void Demo()
        {
            Inventor.Application InvApp = AdnInventorUtilities.InventorApplication;

            _interactionManager = new AdnInteractionManager(InvApp);

            _interactionManager.Initialize();

            _interactionManager.AddPreSelectionFilter(ObjectTypeEnum.kVertexObject);

            _interactionManager.SelectEvents.OnSelect +=
                new SelectEventsSink_OnSelectEventHandler(SelectEvents_OnSelect);

            _interactionManager.DoSelect("Select vertex: ");

            _clientGraphicsMng = new AdnClientGraphicsManager(
                AdnInventorUtilities.InventorApplication,
                AdnInventorUtilities.AddInGuid);

            _clientGraphicsMng.SetGraphicsSource(
                _interactionManager.InteractionEvents);
        }
        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);
        }
Esempio n. 11
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // 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;
            }
        }