コード例 #1
0
        public override void Update()
        {
            AdnInventorUtilities.Timer Timer = new AdnInventorUtilities.Timer();

            while (_radius < 0.3)
            {
                double dT = Timer.ElapsedSeconds;

                _radius += dT * _speed;

                this.DeleteGraphics();

                SurfaceBody surface =
                    AdnInventorUtilities.InventorApplication.TransientBRep.CreateSolidSphere(
                        _pos,
                        _radius);

                SurfaceGraphics surfGraph = this.GraphicsManager.DrawSurface(
                    surface,
                    this.GraphicsNode);

                this.GraphicsManager.UpdateView();
            }

            this.DeleteGraphics();
            this.GraphicsManager.UpdateView();
        }
コード例 #2
0
        //////////////////////////////////////////////////////////////////////////////////////////////
        //
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        void InsertAsSurfaceGraphics(Matrix transfo)
        {
            Inventor.Application InvApp = AdnInventorUtilities.InvApplication;

            Document document = InvApp.ActiveDocument;

            ComponentDefinition compDef =
                AdnInventorUtilities.GetCompDefinition(document);

            _clientGraphicsMng.SetGraphicsSource(InvApp.ActiveDocument);

            Dictionary <SurfaceBody, SurfaceBody> surfaceBodies =
                AdnInventorUtilities.GetTransientBodies(
                    AdnInventorUtilities.GetCompDefinition(_componentDocument));

            foreach (KeyValuePair <SurfaceBody, SurfaceBody> pair in surfaceBodies)
            {
                SurfaceGraphics surfGraph = _clientGraphicsMng.DrawSurface(pair.Value);

                GraphicsNode node = surfGraph.Parent;

                node.Transformation = transfo;
                node.Selectable     = true;

                StyleSourceTypeEnum styleSourceType;
                node.RenderStyle = pair.Key.GetRenderStyle(out styleSourceType);
            }
        }
コード例 #3
0
        //////////////////////////////////////////////////////////////////////////////////////////////
        // Create a list of GraphicsNode, sliced by the plane argument and set their visibility.
        // A list of nodes is used here, so we can attribute each node a different render style
        // if needed.
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        List <GraphicsNode> CreateSlicedNodes(Plane plane, bool visibility)
        {
            List <GraphicsNode> nodes = new List <GraphicsNode>();

            foreach (KeyValuePair <SurfaceBody, SurfaceBody> pair in _surfaceBodies)
            {
                SurfaceGraphics surfGraph = _clientGraphicsMng.DrawSurface(pair.Value);

                GraphicsNode node = surfGraph.Parent;

                StyleSourceTypeEnum styleSourceType;
                node.RenderStyle = pair.Key.GetRenderStyle(out styleSourceType);

                nodes.Add(node);
            }

            ObjectCollection slicingPlanes =
                AdnInventorUtilities.InvApplication.TransientObjects.CreateObjectCollection(null);

            slicingPlanes.Add(plane);

            foreach (GraphicsNode node in nodes)
            {
                node.SliceGraphics(true, slicingPlanes, false, null);

                node.Visible = visibility;

                node.Selectable = true;
            }

            return(nodes);
        }
        public SurfaceGraphics DrawSurface(
            object surface,
            GraphicsNode node)
        {
            try
            {
                AdnGraphics graphicsData = WorkingGraphics;

                if (node == null)
                {
                    node = graphicsData.ClientGraphics.AddNode(
                        graphicsData.GetGraphicNodeFreeId());
                }

                SurfaceGraphics graphic = node.AddSurfaceGraphics(surface);

                return(graphic);
            }
            catch
            {
                return(null);
            }
        }
コード例 #5
0
        //////////////////////////////////////////////////////////////////////////////////////////////
        // Description: Copies SurfaceBody 1 of current part and performs boolean operation
        //              to displays result as SurfaceGraphics.
        //////////////////////////////////////////////////////////////////////////////////////////////
        static public void SurfaceGraphicsDemo()
        {
            PartDocument doc =
                AdnInventorUtilities.InvApplication.ActiveDocument
                as PartDocument;

            string clientId = "{Add-in Guid}";

            ClientGraphics graphics = null;

            try
            {
                graphics = doc.ComponentDefinition.ClientGraphicsCollection[clientId];
            }
            catch
            {
                graphics = doc.ComponentDefinition.ClientGraphicsCollection.Add(clientId);
            }

            // Store utility objects
            TransientGeometry geom = AdnInventorUtilities.InvApplication.TransientGeometry;
            TransientBRep     brep = AdnInventorUtilities.InvApplication.TransientBRep;

            GraphicsNode node = graphics.AddNode(graphics.Count + 1);

            // We will work on the first surface body in our document
            SurfaceBody nativeBody = doc.ComponentDefinition.SurfaceBodies[1];

            // Create a transient copy of the native body to work on it
            SurfaceBody body = brep.Copy(nativeBody);

            // Compute bottom/top points based on body bounding box
            Point bottom = geom.CreatePoint(
                (nativeBody.RangeBox.MinPoint.X + nativeBody.RangeBox.MaxPoint.X) / 2,
                (nativeBody.RangeBox.MinPoint.Y + nativeBody.RangeBox.MaxPoint.Y) / 2,
                nativeBody.RangeBox.MinPoint.Z);

            Point top = geom.CreatePoint(
                (nativeBody.RangeBox.MinPoint.X + nativeBody.RangeBox.MaxPoint.X) / 2,
                (nativeBody.RangeBox.MinPoint.Y + nativeBody.RangeBox.MaxPoint.Y) / 2,
                nativeBody.RangeBox.MaxPoint.Z);

            // Create transient cylinder tool body
            double radius = bottom.DistanceTo(top);

            SurfaceBody tool = brep.CreateSolidCylinderCone(bottom, top, radius, radius, radius, null);

            // Do boolean operation between transient bodies to remove cylinder
            brep.DoBoolean(body, tool, BooleanTypeEnum.kBooleanTypeDifference);

            // Add SurfaceGraphics primitive
            SurfaceGraphics surfGraphPrimitive = node.AddSurfaceGraphics(body);

            // Copy render style of native body if any
            StyleSourceTypeEnum source;
            RenderStyle         style = nativeBody.GetRenderStyle(out source);

            node.RenderStyle = style;

            // Hide native body
            nativeBody.Visible = false;

            doc.Views[1].Update();
        }
コード例 #6
0
        private void DrawCubes()
        {
            try
            {
                var activeDoc = mInventorApp.ActiveDocument as PartDocument;

                var          rubikFile = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location).ToString() + @"\rubik_part.ipt";
                var          rubikDoc  = mInventorApp.Documents.Open(rubikFile, false);
                PartDocument partDoc   = rubikDoc as PartDocument;

                SurfaceBodies surfBodies = partDoc.ComponentDefinition.SurfaceBodies;

                mSurfaceBodies = new List <SurfaceBody>();
                for (int i = 1; i <= surfBodies.Count; i++)
                {
                    mSurfaceBodies.Add(mInventorApp.TransientBRep.Copy(surfBodies[i]));
                }

                // attach IDs to face
                //for (int i = 0; i < mSurfaceBodies.Count; i++)
                //    for (int j = 1; j <= mSurfaceBodies[i].Faces.Count; j++)
                //        mSurfaceBodies[i].Faces[j].AssociativeID = i * 10 + j;

                // iterate over assets and copy them if needed
                for (int i = 1; i <= surfBodies.Count; i++)
                {
                    SurfaceBody surfBody = surfBodies[i];
                    for (int j = 1; j <= surfBody.Faces.Count; j++)
                    {
                        string apperanceName = surfBody.Faces[j].Appearance.DisplayName;
                        try
                        {
                            Asset asset = activeDoc.Assets[apperanceName];
                        }
                        catch (Exception e)
                        {
                            AssetLibrary assetLib = mInventorApp.AssetLibraries["Inventor Material Library"];
                            Asset        asset    = assetLib.AppearanceAssets[apperanceName];
                            asset = asset.CopyTo(activeDoc);
                        }
                    }
                }

                // create the transient graphics of the cubes
                //mClientGraphics = mInventeractionEvents.InteractionGraphics.OverlayClientGraphics;
                mCubes = new List <GraphicsNode>();
                for (int i = 0; i < mSurfaceBodies.Count; i++)
                {
                    GraphicsNode            node         = mClientGraphics.AddNode(mClientGraphics.Count + 1);
                    SurfaceGraphics         surfGraphics = node.AddSurfaceGraphics(mSurfaceBodies[i]);
                    SurfaceGraphicsFaceList surfFaceList = surfGraphics.DisplayedFaces;
                    for (int j = 1; j <= surfFaceList.Count; j++)
                    {
                        string apperanceName = surfBodies[i + 1].Faces[j].Appearance.DisplayName;
                        if (apperanceName == "Default")
                        {
                            apperanceName = "Glossy - Black";
                        }

                        surfFaceList[j].Appearance = activeDoc.Assets[apperanceName];
                        surfFaceList[j].Selectable = true;
                    }

                    surfGraphics.ChildrenAreSelectable = true;
                    node.Selectable = true;
                    //node.AllowSlicing = true;
                    mCubes.Add(node);
                }

                SetLights();
                // set the active view to isometric view
                Camera camera = mInventorApp.ActiveView.Camera;
                camera.ViewOrientationType = ViewOrientationTypeEnum.kIsoTopLeftViewOrientation;
                camera.Fit();
                camera.Apply();

                // close the document
                rubikDoc.ReleaseReference();
                rubikDoc.Close(true);
            }
            catch (Exception e)
            {
            }
        }
コード例 #7
0
        //////////////////////////////////////////////////////////////////////////////////////////////
        // Draws dimension graphics
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        DimData DrawDimension(Point point1, Point point2, Point dimText, Vector normal)
        {
            // Compute extension points
            Vector xAxis = point1.VectorTo(point2);

            Vector upVector = normal.CrossProduct(xAxis);

            upVector.Normalize();

            Plane plane = _Tg.CreatePlane(point1, normal);

            Point dimTextProj = AdnInventorUtilities.ProjectOnPlane(dimText, plane);

            double dotP1 = point1.VectorTo(dimTextProj).DotProduct(upVector);
            double dotP2 = point2.VectorTo(dimTextProj).DotProduct(upVector);

            Point extP1 = _Tg.CreatePoint(
                point1.X + upVector.X * dotP1,
                point1.Y + upVector.Y * dotP1,
                point1.Z + upVector.Z * dotP1);

            Point extP2 = _Tg.CreatePoint(
                point2.X + upVector.X * dotP2,
                point2.Y + upVector.Y * dotP2,
                point2.Z + upVector.Z * dotP2);

            double dimValue = extP1.DistanceTo(extP2);


            GraphicsNode node = _clientGraphicsMng.CreateNewGraphicsNode();

            LineGraphics extLine1 = _clientGraphicsMng.DrawLine(
                AdnInventorUtilities.ToArray(point1),
                AdnInventorUtilities.ToArray(extP1),
                node);

            LineGraphics extLine2 = _clientGraphicsMng.DrawLine(
                AdnInventorUtilities.ToArray(point2),
                AdnInventorUtilities.ToArray(extP2),
                node);

            LineGraphics dimLine = _clientGraphicsMng.DrawLine(
                AdnInventorUtilities.ToArray(extP1),
                AdnInventorUtilities.ToArray(extP2),
                node);

            extLine1.LineType = LineTypeEnum.kDashedLineType;
            extLine2.LineType = LineTypeEnum.kDashedLineType;

            UnitVector v = extP1.VectorTo(extP2).AsUnitVector();

            double length = 20.0;
            double radius = 7.0;

            Point bottom1 = _Tg.CreatePoint(
                extP1.X + length * v.X,
                extP1.Y + length * v.Y,
                extP1.Z + length * v.Z);

            Point bottom2 = _Tg.CreatePoint(
                extP2.X - length * v.X,
                extP2.Y - length * v.Y,
                extP2.Z - length * v.Z);

            SurfaceBody cone1 = _TBrep.CreateSolidCylinderCone(
                bottom1, extP1,
                radius, radius, 0.0, null);

            SurfaceBody cone2 = _TBrep.CreateSolidCylinderCone(
                bottom2, extP2,
                radius, radius, 0.0, null);

            GraphicsNode dimNode = _clientGraphicsMng.CreateNewGraphicsNode();

            SurfaceGraphics arrow1 = _clientGraphicsMng.DrawSurface(cone1, dimNode);
            SurfaceGraphics arrow2 = _clientGraphicsMng.DrawSurface(cone2, dimNode);

            arrow1.SetTransformBehavior(extP1,
                                        DisplayTransformBehaviorEnum.kPixelScaling,
                                        1.0);

            arrow2.SetTransformBehavior(extP2,
                                        DisplayTransformBehaviorEnum.kPixelScaling,
                                        1.0);


            TextGraphics text = _clientGraphicsMng.DrawText(
                AdnInventorUtilities.GetStringFromAPILength(dimValue),
                false,
                dimNode);

            text.Font     = "Arial";
            text.Bold     = false;
            text.Italic   = false;
            text.FontSize = 20;
            text.PutTextColor(221, 0, 0);
            text.VerticalAlignment   = VerticalTextAlignmentEnum.kAlignTextMiddle;
            text.HorizontalAlignment = HorizontalTextAlignmentEnum.kAlignTextLeft;

            Point txtPos = _Tg.CreatePoint(
                (extP1.X + extP2.X) * 0.5,
                (extP1.Y + extP2.Y) * 0.5,
                (extP1.Z + extP2.Z) * 0.5);

            text.Anchor = txtPos;

            text.SetTransformBehavior(txtPos,
                                      DisplayTransformBehaviorEnum.kFrontFacingAndPixelScaling,
                                      1.0);

            node.Selectable    = true;
            dimNode.Selectable = true;

            return(new DimData(point1, point2, extLine1, extLine2, dimLine, dimNode));
        }
コード例 #8
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;
            }
        }
コード例 #9
0
        static public void StandartTest()
        {
            // Set Inventor Application and "activate it"
            TrAddInServer.MApp = null;
            inventordoc        = null;
            // Enable error handling.


            TransientBRep oTransBRep = TrAddInServer.MApp.TransientBRep;


            SurfaceBodyDefinition oSurfaceBodyDef = oTransBRep.CreateSurfaceBodyDefinition();

            TransientGeometry oTG = TrAddInServer.MApp.TransientGeometry;


            LumpDefinition oLumpDef = oSurfaceBodyDef.LumpDefinitions.Add();


            FaceShellDefinition oShell = oLumpDef.FaceShellDefinitions.Add();



            // Define the six planes of the box.
            Plane oPosX;
            Plane oNegX;
            Plane oPosY;
            Plane oNegY;
            Plane oPosZ;
            Plane oNegZ;

            oPosX = oTG.CreatePlane(oTG.CreatePoint(1, 0, 0), oTG.CreateVector(1, 0, 0));
            oNegX = oTG.CreatePlane(oTG.CreatePoint(-1, 0, 0), oTG.CreateVector(-1, 0, 0));
            oPosY = oTG.CreatePlane(oTG.CreatePoint(0, 1, 0), oTG.CreateVector(0, 1, 0));
            oNegY = oTG.CreatePlane(oTG.CreatePoint(0, -1, 0), oTG.CreateVector(0, -1, 0));
            oPosZ = oTG.CreatePlane(oTG.CreatePoint(0, 0, 1), oTG.CreateVector(0, 0, 1));
            oNegZ = oTG.CreatePlane(oTG.CreatePoint(0, 0, -1), oTG.CreateVector(0, 0, -1));

            // Create the six faces.
            FaceDefinition oFaceDefPosX;
            FaceDefinition oFaceDefNegX;
            FaceDefinition oFaceDefPosY;
            FaceDefinition oFaceDefNegY;
            FaceDefinition oFaceDefPosZ;
            FaceDefinition oFaceDefNegZ;

            oFaceDefPosX = oShell.FaceDefinitions.Add(oPosX, false);
            oFaceDefNegX = oShell.FaceDefinitions.Add(oNegX, false);
            oFaceDefPosY = oShell.FaceDefinitions.Add(oPosY, false);
            oFaceDefNegY = oShell.FaceDefinitions.Add(oNegY, false);
            oFaceDefPosZ = oShell.FaceDefinitions.Add(oPosZ, false);
            oFaceDefNegZ = oShell.FaceDefinitions.Add(oNegZ, false);

            // Create the vertices.
            VertexDefinition oVertex1;
            VertexDefinition oVertex2;
            VertexDefinition oVertex3;
            VertexDefinition oVertex4;
            VertexDefinition oVertex5;
            VertexDefinition oVertex6;
            VertexDefinition oVertex7;
            VertexDefinition oVertex8;

            oVertex1 = oSurfaceBodyDef.VertexDefinitions.Add(oTG.CreatePoint(1, 1, 1));
            oVertex2 = oSurfaceBodyDef.VertexDefinitions.Add(oTG.CreatePoint(1, 1, -1));
            oVertex3 = oSurfaceBodyDef.VertexDefinitions.Add(oTG.CreatePoint(-1, 1, -1));
            oVertex4 = oSurfaceBodyDef.VertexDefinitions.Add(oTG.CreatePoint(-1, 1, 1));
            oVertex5 = oSurfaceBodyDef.VertexDefinitions.Add(oTG.CreatePoint(1, -1, 1));
            oVertex6 = oSurfaceBodyDef.VertexDefinitions.Add(oTG.CreatePoint(1, -1, -1));
            oVertex7 = oSurfaceBodyDef.VertexDefinitions.Add(oTG.CreatePoint(-1, -1, -1));
            oVertex8 = oSurfaceBodyDef.VertexDefinitions.Add(oTG.CreatePoint(-1, -1, 1));

            // Define the edges at intersections of the defined planes.
            EdgeDefinition oEdgeDefPosXPosY;
            EdgeDefinition oEdgeDefPosXNegZ;
            EdgeDefinition oEdgeDefPosXNegY;
            EdgeDefinition oEdgeDefPosXPosZ;
            EdgeDefinition oEdgeDefNegXPosY;
            EdgeDefinition oEdgeDefNegXNegZ;
            EdgeDefinition oEdgeDefNegXNegY;
            EdgeDefinition oEdgeDefNegXPosZ;
            EdgeDefinition oEdgeDefPosYNegZ;
            EdgeDefinition oEdgeDefPosYPosZ;
            EdgeDefinition oEdgeDefNegYNegZ;
            EdgeDefinition oEdgeDefNegYPosZ;

            oEdgeDefPosXPosY = oSurfaceBodyDef.EdgeDefinitions.Add(oVertex1, oVertex2, oTG.CreateLineSegment(oVertex1.Position, oVertex2.Position));
            oEdgeDefPosXNegZ = oSurfaceBodyDef.EdgeDefinitions.Add(oVertex2, oVertex6, oTG.CreateLineSegment(oVertex2.Position, oVertex6.Position));
            oEdgeDefPosXNegY = oSurfaceBodyDef.EdgeDefinitions.Add(oVertex6, oVertex5, oTG.CreateLineSegment(oVertex6.Position, oVertex5.Position));
            oEdgeDefPosXPosZ = oSurfaceBodyDef.EdgeDefinitions.Add(oVertex5, oVertex1, oTG.CreateLineSegment(oVertex5.Position, oVertex1.Position));
            oEdgeDefNegXPosY = oSurfaceBodyDef.EdgeDefinitions.Add(oVertex4, oVertex3, oTG.CreateLineSegment(oVertex4.Position, oVertex3.Position));
            oEdgeDefNegXNegZ = oSurfaceBodyDef.EdgeDefinitions.Add(oVertex3, oVertex7, oTG.CreateLineSegment(oVertex3.Position, oVertex7.Position));
            oEdgeDefNegXNegY = oSurfaceBodyDef.EdgeDefinitions.Add(oVertex7, oVertex8, oTG.CreateLineSegment(oVertex7.Position, oVertex8.Position));
            oEdgeDefNegXPosZ = oSurfaceBodyDef.EdgeDefinitions.Add(oVertex8, oVertex4, oTG.CreateLineSegment(oVertex8.Position, oVertex4.Position));
            oEdgeDefPosYNegZ = oSurfaceBodyDef.EdgeDefinitions.Add(oVertex2, oVertex3, oTG.CreateLineSegment(oVertex2.Position, oVertex3.Position));
            oEdgeDefPosYPosZ = oSurfaceBodyDef.EdgeDefinitions.Add(oVertex4, oVertex1, oTG.CreateLineSegment(oVertex4.Position, oVertex1.Position));
            oEdgeDefNegYNegZ = oSurfaceBodyDef.EdgeDefinitions.Add(oVertex7, oVertex6, oTG.CreateLineSegment(oVertex7.Position, oVertex6.Position));
            oEdgeDefNegYPosZ = oSurfaceBodyDef.EdgeDefinitions.Add(oVertex5, oVertex8, oTG.CreateLineSegment(oVertex5.Position, oVertex8.Position));

            // Define the loops on the faces.

            EdgeLoopDefinition oPosXLoop = oFaceDefPosX.EdgeLoopDefinitions.Add();

            oPosXLoop.EdgeUseDefinitions.Add(oEdgeDefPosXPosY, true);
            oPosXLoop.EdgeUseDefinitions.Add(oEdgeDefPosXNegZ, true);
            oPosXLoop.EdgeUseDefinitions.Add(oEdgeDefPosXNegY, true);
            oPosXLoop.EdgeUseDefinitions.Add(oEdgeDefPosXPosZ, true);


            EdgeLoopDefinition oNegXLoop = oFaceDefNegX.EdgeLoopDefinitions.Add();

            oNegXLoop.EdgeUseDefinitions.Add(oEdgeDefNegXPosY, false);
            oNegXLoop.EdgeUseDefinitions.Add(oEdgeDefNegXNegZ, false);
            oNegXLoop.EdgeUseDefinitions.Add(oEdgeDefNegXNegY, false);
            oNegXLoop.EdgeUseDefinitions.Add(oEdgeDefNegXPosZ, false);


            EdgeLoopDefinition oPosYLoop = oFaceDefPosY.EdgeLoopDefinitions.Add();

            oPosYLoop.EdgeUseDefinitions.Add(oEdgeDefPosXPosY, false);
            oPosYLoop.EdgeUseDefinitions.Add(oEdgeDefPosYNegZ, false);
            oPosYLoop.EdgeUseDefinitions.Add(oEdgeDefNegXPosY, true);
            oPosYLoop.EdgeUseDefinitions.Add(oEdgeDefPosYPosZ, false);


            EdgeLoopDefinition oNegYLoop = oFaceDefNegY.EdgeLoopDefinitions.Add();

            oNegYLoop.EdgeUseDefinitions.Add(oEdgeDefPosXNegY, false);
            oNegYLoop.EdgeUseDefinitions.Add(oEdgeDefNegYPosZ, false);
            oNegYLoop.EdgeUseDefinitions.Add(oEdgeDefNegXNegY, true);
            oNegYLoop.EdgeUseDefinitions.Add(oEdgeDefNegYNegZ, false);

            EdgeLoopDefinition oPosZLoop = oFaceDefPosZ.EdgeLoopDefinitions.Add();

            oPosZLoop.EdgeUseDefinitions.Add(oEdgeDefNegXPosZ, true);
            oPosZLoop.EdgeUseDefinitions.Add(oEdgeDefNegYPosZ, true);
            oPosZLoop.EdgeUseDefinitions.Add(oEdgeDefPosXPosZ, false);
            oPosZLoop.EdgeUseDefinitions.Add(oEdgeDefPosYPosZ, true);


            EdgeLoopDefinition oNegZLoop = oFaceDefNegZ.EdgeLoopDefinitions.Add();

            oNegZLoop.EdgeUseDefinitions.Add(oEdgeDefNegXNegZ, true);
            oNegZLoop.EdgeUseDefinitions.Add(oEdgeDefNegYNegZ, true);
            oNegZLoop.EdgeUseDefinitions.Add(oEdgeDefPosXNegZ, false);
            oNegZLoop.EdgeUseDefinitions.Add(oEdgeDefPosYNegZ, true);

            //Create a transient surface body.
            NameValueMap oErrors;

            SurfaceBody oNewBody = oSurfaceBodyDef.CreateTransientSurfaceBody(out oErrors);

            // Create client graphics to display the transient body.

            PartDocument oDoc = (PartDocument)TrAddInServer.MApp.Documents.Add(DocumentTypeEnum.kPartDocumentObject);


            PartComponentDefinition oDef = oDoc.ComponentDefinition;


            ClientGraphics oClientGraphics = oDef.ClientGraphicsCollection.Add("Sample3DGraphicsID");

            // Create a new graphics node within the client graphics objects.
            GraphicsNode oSurfacesNode = oClientGraphics.AddNode(1);

            // Create client graphics based on the transient body
            SurfaceGraphics oSurfaceGraphics = oSurfacesNode.AddSurfaceGraphics(oNewBody);

            // Update the view.
            TrAddInServer.MApp.ActiveView.Update();
        }