//////////////////////////////////////////////////////////////////////////////////////////////
        // OnMouseDown Event: we create symbol in the sheet graphics by using SetGraphicsSource(sheet)
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        void MouseEvents_OnMouseDown(
            MouseButtonEnum Button,
            ShiftStateEnum ShiftKeys,
            Inventor.Point ModelPosition,
            Point2d ViewPosition,
            Inventor.View View)
        {
            if (Button != MouseButtonEnum.kLeftMouseButton)
            {
                return;
            }

            // Define symbol inputs: center, normal, radius

            Point center = ModelPosition;

            UnitVector normal = _Tg.CreateUnitVector(0, 0, 1);

            double radius = _sheet.Width / 30;

            // Add new symbol to the sheet graphics...
            _clientGraphicsMng.SetGraphicsSource(_sheet);

            DrawSymbol(normal, center, radius);

            _clientGraphicsMng.UpdateView();

            _clientGraphicsMng.SetGraphicsSource(
                _interactionManager.InteractionEvents);

            _symbolNode = null;
        }
Exemplo n.º 2
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;
        }
Exemplo 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;
        }
Exemplo n.º 4
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);
        }
        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: ");
        }
Exemplo n.º 6
0
        //////////////////////////////////////////////////////////////////////////////////////////////
        //
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        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);
        }
        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;
        }
Exemplo n.º 8
0
        //////////////////////////////////////////////////////////////////////////////////////////////
        // Creates ClientFeature that holds our dimension graphics
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        void CreateClientFeature(Point point1, Point point2, Point dimText, Vector normal)
        {
            Inventor.Application InvApp = AdnInventorUtilities.InvApplication;

            Document document = InvApp.ActiveDocument;

            ComponentDefinition compDef =
                AdnInventorUtilities.GetCompDefinition(document);

            object features =
                AdnInventorUtilities.GetProperty(compDef, "Features");

            ClientFeatures clientFeatures =
                AdnInventorUtilities.GetProperty(features, "ClientFeatures")
                as ClientFeatures;

            ClientFeatureDefinition cfDef =
                clientFeatures.CreateDefinition(
                    "Dimension Feature",
                    null, null, null);

            ClientFeature clientFeature =
                clientFeatures.Add(cfDef, AdnInventorUtilities.AddInGuid);

            cfDef = clientFeature.Definition;

            cfDef.HighlightClientGraphicsWithFeature = true;

            NativeBrowserNodeDefinition nodeDef =
                clientFeature.BrowserNode.BrowserNodeDefinition as NativeBrowserNodeDefinition;

            stdole.IPictureDisp pic =
                PictureDispConverter.ToIPictureDisp(Resources.dimlinear);

            ClientNodeResource res =
                document.BrowserPanes.ClientNodeResources.Add(
                    AdnInventorUtilities.AddInGuid,
                    document.BrowserPanes.ClientNodeResources.Count + 1,
                    pic);

            nodeDef.OverrideIcon = res;

            _clientGraphicsMng.SetGraphicsSource(clientFeature);

            DrawDimension(point1, point2, dimText, normal);

            _clientGraphicsMng.UpdateView();
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
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);
        }
        //////////////////////////////////////////////////////////////////////////////////////////////
        // Description: Displays a LineGraphics between points [0, 0, 0] and [1, 1, 1]
        //              using AdnClientGraphicsManager
        //////////////////////////////////////////////////////////////////////////////////////////////
        public static void Demo()
        {
            Inventor.Application InvApp = AdnInventorUtilities.InvApplication;

            double[] startPoint = new double[] { 0.0, 0.0, 0.0 };
            double[] endPoint   = new double[] { 1.0, 1.0, 1.0 };

            // Create instance of AdnClientGraphicsManager
            AdnClientGraphicsManager clientGraphicsMng =
                new AdnClientGraphicsManager(InvApp, AdnInventorUtilities.AddInGuid);

            // Set document as current graphics source
            clientGraphicsMng.SetGraphicsSource(InvApp.ActiveDocument);

            // Create LineGraphics primitive
            LineGraphics lineGraph = clientGraphicsMng.DrawLine(startPoint, endPoint);

            lineGraph.LineWeight = 5.0;

            // Update view to see results
            clientGraphicsMng.UpdateView();
        }
        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);
        }
Exemplo n.º 14
0
        //////////////////////////////////////////////////////////////////////////////////////////////
        // Example using the AdnClientGraphicsManager
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        public static void DemoMng()
        {
            Inventor.Application InvApp = AdnInventorUtilities.InvApplication;

            Document document = InvApp.ActiveDocument;

            // We will use late binding to retrieve ClientFeatures collection,
            // so we dont need to write specific code for PartDocument and
            // AssemblyDocument
            ComponentDefinition compDef =
                AdnInventorUtilities.GetCompDefinition(document);

            object features =
                AdnInventorUtilities.GetProperty(compDef, "Features");

            ClientFeatures clientFeatures =
                AdnInventorUtilities.GetProperty(features, "ClientFeatures")
                as ClientFeatures;

            ClientFeatureDefinition cfDef =
                clientFeatures.CreateDefinition("Graphics Feature", null, null, null);

            ClientFeature clientFeature =
                clientFeatures.Add(cfDef, AdnInventorUtilities.AddInGuid);

            cfDef = clientFeature.Definition;

            cfDef.HighlightClientGraphicsWithFeature = true;

            NativeBrowserNodeDefinition nodeDef =
                clientFeature.BrowserNode.BrowserNodeDefinition as NativeBrowserNodeDefinition;

            stdole.IPictureDisp pic =
                PictureDispConverter.ToIPictureDisp(Resources.PointImage);

            ClientNodeResource res =
                document.BrowserPanes.ClientNodeResources.Add(
                    AdnInventorUtilities.AddInGuid,
                    document.BrowserPanes.ClientNodeResources.Count + 1,
                    pic);

            nodeDef.OverrideIcon = res;

            AdnClientGraphicsManager clientGraphicsMng = new AdnClientGraphicsManager(
                InvApp,
                AdnInventorUtilities.AddInGuid);

            clientGraphicsMng.SetGraphicsSource(clientFeature);

            Random rd = new Random();

            TriangleGraphics graphics = clientGraphicsMng.DrawTriangle(
                new double[] { rd.Next(0, 10), rd.Next(0, 10), rd.Next(0, 10) },
                new double[] { rd.Next(0, 10), rd.Next(0, 10), rd.Next(0, 10) },
                new double[] { rd.Next(0, 10), rd.Next(0, 10), rd.Next(0, 10) },
                null);

            int id = clientGraphicsMng.WorkingGraphics.GetDataSetFreeId();

            GraphicsColorSet colorSet =
                clientGraphicsMng.WorkingGraphics.GraphicsDataSets.CreateColorSet(id);

            colorSet.Add(1, (byte)rd.Next(0, 255), (byte)rd.Next(0, 255), (byte)rd.Next(0, 255));

            graphics.ColorSet = colorSet;

            clientGraphicsMng.UpdateView();
        }
Exemplo n.º 15
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;
            }
        }