Exemplo n.º 1
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: ");
        }
Exemplo n.º 3
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.º 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);
        }
        //////////////////////////////////////////////////////////////////////////////////////////////
        // Deletes all graphics created by ClientGraphicsManager
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        public static void DeleteManagerGraphics()
        {
            Inventor.Application InvApp = AdnInventorUtilities.InvApplication;

            Document document = InvApp.ActiveDocument;

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

            switch (document.DocumentType)
            {
            case DocumentTypeEnum.kAssemblyDocumentObject:
            case DocumentTypeEnum.kPartDocumentObject:

                clientGraphicsMng.DeleteGraphics(document, true);
                break;

            case DocumentTypeEnum.kDrawingDocumentObject:

                DrawingDocument drawing = document as DrawingDocument;
                clientGraphicsMng.DeleteGraphics(drawing.ActiveSheet, true);
                break;

            default:
                break;
            }

            clientGraphicsMng.UpdateView();
        }
Exemplo n.º 6
0
        //////////////////////////////////////////////////////////////////////////////////////////////
        // The public static method to start the demo
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        public static void Demo()
        {
            Inventor.Application InvApp = AdnInventorUtilities.InvApplication;

            object selection = InvApp.CommandManager.Pick(
                SelectionFilterEnum.kPartBodyFilter,
                "Select a SurfaceBody: ");

            if (selection == null)
            {
                return;
            }

            SurfaceBody body = selection as SurfaceBody;

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

            GraphicsNode node = clientGraphicsMng.CreateNewGraphicsNode();

            foreach (Edge edge in body.Edges)
            {
                CurveGraphics graphic = clientGraphicsMng.DrawCurve(edge.Geometry, node);

                graphic.LineWeight         = 5.0;
                graphic.Parent.RenderStyle = InvApp.ActiveDocument.RenderStyles["Red"];
            }

            clientGraphicsMng.UpdateView();
        }
        //////////////////////////////////////////////////////////////////////////////////////////////
        // The public static method to start the demo
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        public static void Demo()
        {
            Inventor.Application InvApp = AdnInventorUtilities.InvApplication;

            object selection1 = InvApp.CommandManager.Pick(
                SelectionFilterEnum.kPartVertexFilter,
                "Select first vertex: ");

            if (selection1 == null)
            {
                return;
            }

            object selection2 = InvApp.CommandManager.Pick(
                SelectionFilterEnum.kPartVertexFilter,
                "Select second vertex: ");

            if (selection2 == null)
            {
                return;
            }

            object selection3 = InvApp.CommandManager.Pick(
                SelectionFilterEnum.kPartVertexFilter,
                "Select third vertex: ");

            if (selection3 == null)
            {
                return;
            }

            List <double> coords = new List <double>();

            coords.AddRange(AdnInventorUtilities.ToArray(AdnInventorUtilities.GetPoint(selection1)));
            coords.AddRange(AdnInventorUtilities.ToArray(AdnInventorUtilities.GetPoint(selection2)));
            coords.AddRange(AdnInventorUtilities.ToArray(AdnInventorUtilities.GetPoint(selection3)));

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

            LineStripGraphics lineStrip =
                clientGraphicsMng.DrawLineStrip(coords.ToArray());

            lineStrip.LineWeight = 5.0;

            int id = clientGraphicsMng.WorkingGraphics.GetDataSetFreeId();

            lineStrip.ColorSet =
                clientGraphicsMng.WorkingGraphics.GraphicsDataSets.CreateColorSet(id);

            lineStrip.ColorSet.Add(1, 119, 187, 17);

            clientGraphicsMng.UpdateView();
        }
Exemplo n.º 8
0
 public VertexSelectEffect(
     AdnClientGraphicsManager clientGraphicsMng, 
     Point pos, 
     double radius, 
     double speed): 
     base(clientGraphicsMng)
 {
     _pos = pos;
     _radius = radius;
     _speed = speed;
 }
Exemplo n.º 9
0
 public VertexSelectEffect(
     AdnClientGraphicsManager clientGraphicsMng,
     Point pos,
     double radius,
     double speed) :
     base(clientGraphicsMng)
 {
     _pos    = pos;
     _radius = radius;
     _speed  = speed;
 }
        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.º 11
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.º 12
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.º 13
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.º 16
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.º 17
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;
            }
        }