• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Solid类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Solid的典型用法代码示例。如果您正苦于以下问题:C# Solid类的具体用法?C# Solid怎么用?C# Solid使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Solid类属于命名空间,在下文中一共展示了Solid类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetProfile

 GetProfile(Solid solid, double offset, Revit.ApplicationServices.Application app)
 {
     CurveArray curveArray = app.Create.NewCurveArray();
     EdgeArray edgeArray = GetEdgesOnPlaneAtOffset(solid.Edges, GeomUtils.kZAxis, offset);
     curveArray = ToCurveArray(edgeArray, curveArray);
     return curveArray;
 }
开发者ID:15921050052,项目名称:RevitLookup,代码行数:7,代码来源:Geometry.cs


示例2: Create

        /// <summary>
        /// Creates a SimpleSweptSolidAnalyzer and computes the swept solid.
        /// </summary>
        /// <param name="solid">The solid geometry.</param>
        /// <param name="normal">The normal of the reference plane that a path might lie on.  If it is null, try to guess based on the geometry.</param>
        /// <returns>The analyzer.</returns>
        public static SimpleSweptSolidAnalyzer Create(Solid solid, XYZ normal)
        {
            if (solid == null)
                throw new ArgumentNullException();

            ICollection<Face> faces = new List<Face>();
            foreach (Face face in solid.Faces)
            {
                faces.Add(face);
            }
            return Create(faces, normal);
        }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:18,代码来源:SimpleSweptSolidAnalyzer.cs


示例3: Create

        /// <summary>
        /// Creates a SweptSolidExporter.
        /// </summary>
        /// <param name="exporterIFC">The exporter.</param>
        /// <param name="element">The element.</param>
        /// <param name="solid">The solid.</param>
        /// <param name="normal">The normal of the plane that the path lies on.</param>
        /// <returns>The SweptSolidExporter.</returns>
        public static SweptSolidExporter Create(ExporterIFC exporterIFC, Element element, Solid solid, XYZ normal)
        {
            try
            {
                SweptSolidExporter sweptSolidExporter = null;
                SimpleSweptSolidAnalyzer sweptAnalyzer = SimpleSweptSolidAnalyzer.Create(element.Document.Application.Create, solid, normal);
                if (sweptAnalyzer != null)
                {
                    // TODO: support openings and recess for a swept solid
                    if (sweptAnalyzer.UnalignedFaces != null && sweptAnalyzer.UnalignedFaces.Count > 0)
                        return null;

                    IList<GeometryUtil.FaceBoundaryType> faceBoundaryTypes;
                    IList<CurveLoop> faceBoundaries = GeometryUtil.GetFaceBoundaries(sweptAnalyzer.ProfileFace, null, out faceBoundaryTypes);

                    string profileName = null;
                    if (element != null)
                    {
                        ElementType type = element.Document.GetElement(element.GetTypeId()) as ElementType;
                        if (type != null)
                            profileName = type.Name;
                    }

                    // is extrusion?
                    if (sweptAnalyzer.PathCurve is Line)
                    {
                        Line line = sweptAnalyzer.PathCurve as Line;

                        // invalid case
                        if (MathUtil.VectorsAreOrthogonal(line.Direction, sweptAnalyzer.ProfileFace.Normal))
                            return null;

                        sweptSolidExporter = new SweptSolidExporter();
                        sweptSolidExporter.m_IsExtrusion = true;
                        Plane plane = new Plane(sweptAnalyzer.ProfileFace.Normal, sweptAnalyzer.ProfileFace.Origin);
                        sweptSolidExporter.m_RepresentationItem = ExtrusionExporter.CreateExtrudedSolidFromCurveLoop(exporterIFC, profileName, faceBoundaries, plane,
                            line.Direction, line.Length * exporterIFC.LinearScale);
                    }
                    else
                    {
                        sweptSolidExporter = new SweptSolidExporter();
                        sweptSolidExporter.m_RepresentationItem = CreateSimpleSweptSolid(exporterIFC, profileName, faceBoundaries, normal, sweptAnalyzer.PathCurve);
                    }
                }
                return sweptSolidExporter;
            }
            catch (Exception)
            {
                return null;
            }
        }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:59,代码来源:SweptSolidExporter.cs


示例4: TestCreate

        public void TestCreate()
        {
            var solid = new Solid();
            Assert.Null(solid.Name);
            Assert.Equal(SolidFormat.Memory, solid.Format);
            Assert.NotNull(solid.Facets);
            Assert.Equal(0, solid.Facets.Count);

            solid = new Solid("Test", new Facet[] { new Facet(), new Facet() });
            Assert.Equal("Test", solid.Name);
            Assert.Equal(SolidFormat.Memory, solid.Format);
            Assert.NotNull(solid.Facets);
            Assert.Equal(2, solid.Facets.Count);
        }
开发者ID:frenchmakers,项目名称:StlLibSharp,代码行数:14,代码来源:SolidTest.cs


示例5: Create

        /// <summary>
        /// Creates a SimpleSweptSolidAnalyzer and computes the swept solid.
        /// </summary>
        /// <param name="solid">The solid geometry.</param>
        /// <param name="normal">The normal of the reference plane that a path might lie on.</param>
        /// <returns>The analyzer.</returns>
        public static SimpleSweptSolidAnalyzer Create(Autodesk.Revit.Creation.Application creation, Solid solid, XYZ normal)
        {
            if (solid == null || normal == null)
                throw new ArgumentNullException();

            m_appCreation = creation;

            ICollection<Face> faces = new List<Face>();
            foreach (Face face in solid.Faces)
            {
                faces.Add(face);
            }
            return Create(faces, normal);
        }
开发者ID:whztt07,项目名称:RevitIFC,代码行数:20,代码来源:SimpleSweptSolidAnalyzer.cs


示例6: Clone

        public static Solid Clone( /*this*/ Solid solid )
        {
            if( solid == null )
              {
            return null;
              }

              // Better than unioning the solid with itself:
              // use a small cube contained within the original
              // solid instead, e.g. a 1x1x1 cube at the origin
              // or something.

              return BooleanOperationsUtils
            .ExecuteBooleanOperation( solid, solid,
              BooleanOperationsType.Union );
        }
开发者ID:nbright,项目名称:the_building_coder_samples,代码行数:16,代码来源:CmdExportSolidToSat.cs


示例7: Slicer

 /// <summary>
 /// creates slices using a curve as the spine
 /// </summary>
 /// <param name="solid">Solid: geometry that is to be parsed</param>
 /// <param name="curve">Curve: defines the normal used to create cut planes perpendicular to parameter "plane".
 /// If curve is too short, it will be extended using built-in extend function</param>
 /// <param name="thickness">Thickness: the thickness of the slices, or the thickness of the material to be used for the assembly</param>
 /// <param name="spacing">Spacing: the distance between each slice</param>
 /// <returns>A newly-constructed Slicer object</returns>
 internal Slicer(Solid solid, Curve curve, double thickness, double spacing, double origin)
 {
     Solid = solid;
     Thickness = thickness;
     Spacing = spacing;
     Plane plane = Plane.ByOriginNormal(curve.StartPoint, curve.Normal);
     Curve curvePlanar = curve;
     if(!curve.IsPlanar)
     {
         plane = Plane.ByBestFitThroughPoints(curve.ToNurbsCurve().ControlPoints());
         curvePlanar = curve.PullOntoPlane(plane);
     }
     CutPlanesPrimary.AddRange(GenerateCutPlanes(plane));
     CutPlanesSecondary.AddRange(GenerateCutPlanes(curvePlanar, origin));
     InitialGeometry = new List<Geometry>(1){curvePlanar};
 }
开发者ID:Hanxuelong,项目名称:BecauseWeDynamo,代码行数:25,代码来源:Slicer.cs


示例8: CanExportAsSweptSolid

        /// <summary>
        /// Determines if we can create a swept solid from the passed in geometry.
        /// </summary>
        /// <param name="exporterIFC">The exporter.</param>
        /// <param name="element">The element.</param>
        /// <param name="solid">The solid.</param>
        /// <param name="normal">The optional normal of the plane that the path lies on.</param>
        /// <returns>If it is possible to create a swept solid, the SimpleSweptSolidAnalyzer that contains the information, otherwise null.</returns>
        public static SimpleSweptSolidAnalyzer CanExportAsSweptSolid(ExporterIFC exporterIFC, Solid solid, XYZ normal)
        {
            try
            {
                SimpleSweptSolidAnalyzer sweptAnalyzer = SimpleSweptSolidAnalyzer.Create(solid, normal);
                if (sweptAnalyzer == null)
                    return null;

                // TODO: support openings and recess for a swept solid
                if (sweptAnalyzer.UnalignedFaces != null && sweptAnalyzer.UnalignedFaces.Count > 0)
                    return null;

                return sweptAnalyzer;
            }
            catch (Exception)
            {
                return null;
            }
        }
开发者ID:whztt07,项目名称:RevitIFC,代码行数:27,代码来源:SweptSolidExporter.cs


示例9: WorldDraw

        public override bool WorldDraw(Drawable drawable, WorldDraw wd)
        {
            if (wd.RegenAbort || wd.IsDragging)
            {
                return base.WorldDraw(drawable, wd);
            }

            RebarPos pos = drawable as RebarPos;
            if (pos == null || (pos.IncludeInBOQ && !pos.Detached))
            {
                return base.WorldDraw(drawable, wd);
            }

            // Get geometry
            Point3d minpt;
            Point3d maxpt;
            pos.TextBox(out minpt, out maxpt);
            minpt = minpt.DivideBy(pos.Scale);
            maxpt = maxpt.DivideBy(pos.Scale);

            using (Solid solid = new Solid())
            {
                solid.SetPointAt(0, new Point3d(minpt.X - 0.15, minpt.Y - 0.15, 0));
                solid.SetPointAt(1, new Point3d(maxpt.X + 0.15, minpt.Y - 0.15, 0));
                solid.SetPointAt(2, new Point3d(minpt.X - 0.15, maxpt.Y + 0.15, 0));
                solid.SetPointAt(3, new Point3d(maxpt.X + 0.15, maxpt.Y + 0.15, 0));
                solid.Color = mColor;
                solid.LayerId = PosUtility.DefpointsLayer;

                Matrix3d trans = Matrix3d.AlignCoordinateSystem(
                    Point3d.Origin, Vector3d.XAxis, Vector3d.YAxis, Vector3d.ZAxis,
                    pos.BasePoint, pos.DirectionVector, pos.UpVector, pos.NormalVector);

                solid.TransformBy(trans);
                wd.Geometry.Draw(solid);
            }

            // Draw the entity over shading
            return base.WorldDraw(drawable, wd);
        }
开发者ID:oozcitak,项目名称:RebarPos,代码行数:40,代码来源:CountOverrule.cs


示例10: GetDifferenceFromWallJoins

        private static bool GetDifferenceFromWallJoins(Document doc, ElementId wallId, Solid baseSolid, IList<IList<IFCConnectedWallData>> connectedWalls)
        {
            Options options = GeometryUtil.GetIFCExportGeometryOptions();
            foreach (IList<IFCConnectedWallData> wallDataList in connectedWalls)
            {
                foreach (IFCConnectedWallData wallData in wallDataList)
                {
                    ElementId otherWallId = wallData.ElementId;
                    if (otherWallId == wallId)
                        continue;

                    Element otherElem = doc.GetElement(otherWallId);
                    GeometryElement otherGeomElem = (otherElem != null) ? otherElem.get_Geometry(options) : null;
                    if (otherGeomElem == null)
                        continue;

                    SolidMeshGeometryInfo solidMeshInfo = GeometryUtil.GetSplitSolidMeshGeometry(otherGeomElem);
                    if (solidMeshInfo.GetMeshes().Count != 0)
                        return false;

                    IList<Solid> otherSolids = solidMeshInfo.GetSolids();
                    foreach (Solid otherSolid in otherSolids)
                    {
                        try
                        {
                            BooleanOperationsUtils.ExecuteBooleanOperationModifyingOriginalSolid(baseSolid, otherSolid, BooleanOperationsType.Difference);
                        }
                        catch
                        {
                            return false;
                        }
                    }
                }
            }

            return true;
        }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:37,代码来源:WallExporter.cs


示例11: TestTextWriter

        public void TestTextWriter()
        {
            Solid solid1 = new Solid("test", new List<Facet>()
            {
                new Facet(new Vertex( 0.23f, 0, 1), new Vertex[]
                {
                    new Vertex( 0, 0, 0),
                    new Vertex(-10.123f, -10, 0),
                    new Vertex(-10.123f, 0, 0)
                }, 0)
            });

            byte[] data;
            string dataString1;

            using (MemoryStream stream = new MemoryStream())
            using (var writer = new StlTextWriter(stream))
            {
                writer.WriteSolid(solid1);
                data = stream.ToArray();
                dataString1 = Consts.FileEncoding.GetString(data);
            }

            Solid solid2;

            using (MemoryStream stream = new MemoryStream(data))
            using (var reader = new StlReader(stream))
            {
                solid2 = reader.ReadSolid();
            }

            Assert.Equal(solid1.Name, solid2.Name);
            Assert.Equal(solid1.Facets.Count, solid2.Facets.Count);
            for (int i = 0; i < solid1.Facets.Count; i++)
                Assert.True(solid1.Facets[i].Equals(solid2.Facets[i]));

        }
开发者ID:frenchmakers,项目名称:StlLibSharp,代码行数:37,代码来源:WriterTest.cs


示例12: TestBinaryWriter

        public void TestBinaryWriter()
        {
            Solid solid1 = new Solid("test", new Facet[]
            {
                new Facet(new Vertex( 0, 0, 1), new Vertex[]
                {
                    new Vertex( 0, 0, 0),
                    new Vertex(-10, -10, 0),
                    new Vertex(-10, 0, 0)
                }, 0)
            });

            byte[] data;

            using (MemoryStream stream = new MemoryStream())
            using (var writer = new StlBinaryWriter(stream))
            {
                writer.WriteSolid(solid1);
                data = stream.ToArray();
            }

            Solid solid2;

            using (MemoryStream stream = new MemoryStream(data))
            using (var reader = new StlReader(stream))
            {
                solid2 = reader.ReadSolid();
            }

            Assert.NotEqual(solid1.Name, solid2.Name);
            Assert.Null(solid2.Name);
            Assert.Equal(solid1.Facets.Count, solid2.Facets.Count);
            for (int i = 0; i < solid1.Facets.Count; i++)
                Assert.True(solid1.Facets[i].Equals(solid2.Facets[i]));

        }
开发者ID:frenchmakers,项目名称:StlLibSharp,代码行数:36,代码来源:WriterTest.cs


示例13: getFaceNaos

        /// <summary>
        /// Retrieve the planar face normal and origin
        /// from all of the solid's planar faces and
        /// insert them into the map mapping face normals
        /// to a list of all origins of different faces
        /// sharing this normal.
        /// </summary>
        /// <param name="naos">Map mapping each normal vector
        /// to a list of the origins of all planar faces
        /// sharing this normal direction</param>
        /// <param name="solid">Input solid</param>
        void getFaceNaos(
            Dictionary<XYZ, List<XYZ>> naos,
            Solid solid)
        {
            foreach( Face face in solid.Faces )
              {
            PlanarFace planarFace = face as PlanarFace;
            if( null != planarFace )
            {
              XYZ normal = planarFace.Normal;
              XYZ origin = planarFace.Origin;
              List<XYZ> normals = new List<XYZ>( naos.Keys );
              int i = normals.FindIndex(
            delegate( XYZ v )
            {
              return XyzParallel( v, normal );
            } );

              if( -1 == i )
              {
            Debug.Print(
                "Face at {0} has new normal {1}",
                Util.PointString( origin ),
                Util.PointString( normal ) );

            naos.Add( normal, new List<XYZ>() );
            naos[normal].Add( origin );
              }
              else
              {
            Debug.Print(
                "Face at {0} normal {1} matches {2}",
                Util.PointString( origin ),
                Util.PointString( normal ),
                Util.PointString( normals[i] ) );

            naos[normals[i]].Add( origin );
              }
            }
              }
        }
开发者ID:JesseMom,项目名称:the_building_coder_samples,代码行数:52,代码来源:CmdWallDimensions.cs


示例14: GetTopFace

 /// <summary>
 /// Return the uppermost horizontal face
 /// of a given "horizontal" solid object
 /// such as a floor slab. Currently only
 /// supports planar faces.
 /// </summary>
 PlanarFace GetTopFace( Solid solid )
 {
     PlanarFace topFace = null;
       FaceArray faces = solid.Faces;
       foreach( Face f in faces )
       {
     PlanarFace pf = f as PlanarFace;
     if( null != pf
       && Util.IsHorizontal( pf ) )
     {
       if( ( null == topFace )
     || ( topFace.Origin.Z < pf.Origin.Z ) )
       {
     topFace = pf;
       }
     }
       }
       return topFace;
 }
开发者ID:JesseMom,项目名称:the_building_coder_samples,代码行数:25,代码来源:CmdEditFloor.cs


示例15: CreateSimpleSweptSolid

        /// <summary>
        /// Creates a simple swept solid.
        /// </summary>
        /// <param name="exporterIFC">The exporter.</param>
        /// <param name="element">The element.</param>
        /// <param name="solid">The solid.</param>
        /// <param name="normal">The normal of the plane that the path lies on.</param>
        /// <returns>The swept solid representation handle.</returns>
        public static IFCAnyHandle CreateSimpleSweptSolid(ExporterIFC exporterIFC, Element element, Solid solid, XYZ normal)
        {
            try
            {
                if (element == null || element.Document == null)
                    return null;

                SimpleSweptSolidAnalyzer sweptAnalyzer = SimpleSweptSolidAnalyzer.Create(element.Document.Application.Create, solid, normal);
                if (sweptAnalyzer != null)
                {
                    // TODO: support openings and recess for a swept solid
                    if (sweptAnalyzer.UnalignedFaces != null && sweptAnalyzer.UnalignedFaces.Count > 0)
                        return null;

                    IList<GeometryUtil.FaceBoundaryType> faceBoundaryTypes;
                    IList<CurveLoop> faceBoundaries = GeometryUtil.GetFaceBoundaries(sweptAnalyzer.ProfileFace, null, out faceBoundaryTypes);

                    string profileName = null;
                    if (element != null)
                    {
                        ElementType type = element.Document.GetElement(element.GetTypeId()) as ElementType;
                        if (type != null)
                            profileName = type.Name;
                    }

                    return CreateSimpleSweptSolid(exporterIFC, profileName, faceBoundaries, normal, sweptAnalyzer.PathCurve);
                }
            }
            catch (Exception)
            {
                return null;
            }

            return null;
        }
开发者ID:stiter,项目名称:ifcexporter,代码行数:43,代码来源:SweptSolidExporter.cs


示例16: CreateOpening

        /// <summary>
        /// Creates an opening from a solid.
        /// </summary>
        /// <param name="exporterIFC">The exporter.</param>
        /// <param name="hostObjHnd">The host object handle.</param>
        /// <param name="hostElement">The host element.</param>
        /// <param name="insertElement">The insert element.</param>
        /// <param name="openingGUID">The GUID for the opening, depending on how the opening is created.</param>
        /// <param name="solid">The solid.</param>
        /// <param name="scaledHostWidth">The scaled host width.</param>
        /// <param name="isRecess">True if it is recess.</param>
        /// <param name="extrusionCreationData">The extrusion creation data.</param>
        /// <param name="setter">The placement setter.</param>
        /// <param name="localWrapper">The product wrapper.</param>
        /// <returns>The created opening handle.</returns>
        static public IFCAnyHandle CreateOpening(ExporterIFC exporterIFC, IFCAnyHandle hostObjHnd, Element hostElement, Element insertElement, string openingGUID,
            Solid solid, double scaledHostWidth, bool isRecess, IFCExtrusionCreationData extrusionCreationData, PlacementSetter setter, ProductWrapper localWrapper)
        {
            IFCFile file = exporterIFC.GetFile();

            ElementId catId = CategoryUtil.GetSafeCategoryId(insertElement);

            XYZ prepToWall;
            bool isLinearWall = GetOpeningDirection(hostElement, out prepToWall);
            if (isLinearWall)
            {
                extrusionCreationData.CustomAxis = prepToWall;
                extrusionCreationData.PossibleExtrusionAxes = IFCExtrusionAxes.TryCustom;
            }

            BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
            BodyData bodyData = BodyExporter.ExportBody(exporterIFC, insertElement, catId, ElementId.InvalidElementId,
                solid, bodyExporterOptions, extrusionCreationData);

            IFCAnyHandle openingRepHnd = bodyData.RepresentationHnd;
            if (IFCAnyHandleUtil.IsNullOrHasNoValue(openingRepHnd))
            {
                extrusionCreationData.ClearOpenings();
                return null;
            }
            IList<IFCAnyHandle> representations = new List<IFCAnyHandle>();
            representations.Add(openingRepHnd);
            IFCAnyHandle prodRep = IFCInstanceExporter.CreateProductDefinitionShape(file, null, null, representations);

            IFCAnyHandle openingPlacement = extrusionCreationData.GetLocalPlacement();
            IFCAnyHandle hostObjPlacementHnd = IFCAnyHandleUtil.GetObjectPlacement(hostObjHnd);
            Transform relTransform = ExporterIFCUtils.GetRelativeLocalPlacementOffsetTransform(openingPlacement, hostObjPlacementHnd);

            openingPlacement = ExporterUtil.CreateLocalPlacement(file, hostObjPlacementHnd,
                relTransform.Origin, relTransform.BasisZ, relTransform.BasisX);

            IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
            double scaledOpeningLength = extrusionCreationData.ScaledLength;
            string openingObjectType = "Opening";
            if (!MathUtil.IsAlmostZero(scaledHostWidth) && !MathUtil.IsAlmostZero(scaledOpeningLength))
                 openingObjectType = scaledOpeningLength < (scaledHostWidth - MathUtil.Eps()) ? "Recess" : "Opening";
            else
                openingObjectType = isRecess ? "Recess" : "Opening";
            
            string openingName = NamingUtil.GetNameOverride(insertElement, null);
            if (string.IsNullOrEmpty(openingName))
            {
                if (!IFCAnyHandleUtil.IsNullOrHasNoValue(hostObjHnd))
                    openingName = IFCAnyHandleUtil.GetStringAttribute(hostObjHnd, "Name");
                else
                    openingName = NamingUtil.GetNameOverride(hostElement, NamingUtil.CreateIFCObjectName(exporterIFC, hostElement));
            }
            
            IFCAnyHandle openingHnd = IFCInstanceExporter.CreateOpeningElement(file, openingGUID, ownerHistory, openingName, null,
                openingObjectType, openingPlacement, prodRep, null);
            if (ExporterCacheManager.ExportOptionsCache.ExportBaseQuantities)
                PropertyUtil.CreateOpeningQuantities(exporterIFC, openingHnd, extrusionCreationData);

            if (localWrapper != null)
            {
                Element elementForProperties = null;
                if (GUIDUtil.IsGUIDFor(insertElement, openingGUID))
                    elementForProperties = insertElement;

                localWrapper.AddElement(insertElement, openingHnd, setter, extrusionCreationData, true);
            }

            string voidGuid = GUIDUtil.CreateGUID();
            IFCInstanceExporter.CreateRelVoidsElement(file, voidGuid, ownerHistory, null, null, hostObjHnd, openingHnd);
            return openingHnd;
        }
开发者ID:whztt07,项目名称:RevitIFC,代码行数:86,代码来源:OpeningUtil.cs


示例17: GeometrySupport

        /// <summary>
        /// constructor
        /// </summary>
        /// <param name="element">the host object, must be family instance</param>
        /// <param name="geoOptions">the geometry option</param>
        public GeometrySupport(FamilyInstance element, Options geoOptions)
        {
            // get the geometry element of the selected element
            Autodesk.Revit.DB.GeometryElement geoElement = element.get_Geometry(new Options());
            if (null == geoElement || 0 == geoElement.Objects.Size)
            {
                throw new Exception("Can't get the geometry of selected element.");
            }

            AnalyticalModel aModel = element.GetAnalyticalModel();
            if (aModel == null)
            {
                throw new Exception("The selected FamilyInstance don't have AnalyticalModel.");
            }

            AnalyticalModelSweptProfile swProfile = aModel.GetSweptProfile();
            if (swProfile == null || !(swProfile.GetDrivingCurve() is Line))
            {
                throw new Exception("The selected element driving curve is not a line.");
            }

            // get the driving path and vector of the beam or column
            Line line = swProfile.GetDrivingCurve() as Line;
            if (null != line)
            {
                m_drivingLine = line;   // driving path
                m_drivingVector = GeomUtil.SubXYZ(line.get_EndPoint(1), line.get_EndPoint(0));
            }

            //get the geometry object
            foreach (GeometryObject geoObject in geoElement.Objects)
            {
                //get the geometry instance which contain the geometry information
                GeoInstance instance = geoObject as GeoInstance;
                if (null != instance)
                {
                    foreach (GeometryObject o in instance.SymbolGeometry.Objects)
                    {
                        // get the solid of beam of column
                        Solid solid = o as Solid;

                        // do some checks.
                        if (null == solid)
                        {
                            continue;
                        }
                        if (0 == solid.Faces.Size || 0 == solid.Edges.Size)
                        {
                            continue;
                        }

                        m_solid = solid;
                        //get the transform value of instance
                        m_transform = instance.Transform;

                        // Get the swept profile curves information
                        if (!GetSweptProfile(solid))
                        {
                            throw new Exception("Can't get the swept profile curves.");
                        }
                        break;
                    }
                }

            }

            // do some checks about profile curves information
            if (null == m_edges)
            {
                throw new Exception("Can't get the geometry edge information.");
            }
            if (4 != m_points.Count)
            {
                throw new Exception("The sample only work for rectangular beams or columns.");
            }
        }
开发者ID:AMEE,项目名称:revit,代码行数:81,代码来源:GeometrySupport.cs


示例18: GetSweptProfileFace

        /// <summary>
        /// Get the swept profile(face) of the host object(family instance)
        /// </summary>
        /// <param name="solid">the solid reference</param>
        /// <returns>the swept profile</returns>
        private Face GetSweptProfileFace(Solid solid)
        {
            // Get a point on the swept profile from all points in solid
            Autodesk.Revit.DB.XYZ refPoint = new Autodesk.Revit.DB.XYZ ();   // the point on swept profile
            foreach (Edge edge in solid.Edges)
            {
                List<XYZ> points = edge.Tessellate() as List<XYZ>;    //get end points of the edge
                if (2 != points.Count)                   // make sure all edges are lines
                {
                    throw new Exception("All edge should be line.");
                }

                // get two points of the edge. All points in solid should be transform first
                Autodesk.Revit.DB.XYZ first = Transform(points[0]);  // start point of edge
                Autodesk.Revit.DB.XYZ second = Transform(points[1]); // end point of edge

                // some edges should be parallelled with the driving line,
                // and the start point of that edge should be the wanted point
                Autodesk.Revit.DB.XYZ edgeVector = GeomUtil.SubXYZ(second, first);
                if (GeomUtil.IsSameDirection(edgeVector, m_drivingVector))
                {
                    refPoint = first;
                    break;
                }
                if (GeomUtil.IsOppositeDirection(edgeVector, m_drivingVector))
                {
                    refPoint = second;
                    break;
                }
            }

            // Find swept profile(face)
            Face sweptFace = null;  // define the swept face
            foreach (Face face in solid.Faces)
            {
                if (null != sweptFace)
                {
                    break;
                }
                // the swept face should be perpendicular with the driving line
                if (!GeomUtil.IsVertical(face, m_drivingLine, m_transform, null))
                {
                    continue;
                }
                // use the gotted point to get the swept face
                foreach (Autodesk.Revit.DB.XYZ point in face.Triangulate().Vertices)
                {
                    Autodesk.Revit.DB.XYZ pnt = Transform(point); // all points in solid should be transform
                    if (GeomUtil.IsEqual(refPoint, pnt))
                    {
                        sweptFace = face;
                        break;
                    }
                }
            }

            return sweptFace;
        }
开发者ID:AMEE,项目名称:revit,代码行数:63,代码来源:GeometrySupport.cs


示例19: Stream

        private void Stream(ArrayList data, Solid solid)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(Solid)));

            data.Add(new Snoop.Data.Enumerable("Edges", solid.Edges));
            data.Add(new Snoop.Data.Enumerable("Faces", solid.Faces));
            data.Add(new Snoop.Data.Double("Surface area", solid.SurfaceArea));
            data.Add(new Snoop.Data.Double("Volume", solid.Volume));
        }
开发者ID:jeremytammik,项目名称:RevitLookup,代码行数:9,代码来源:CollectorExtGeom.cs


示例20: ValidateGeometry

 /// <summary>
 /// Checks if a Solid is valid for use in a generic DirectShape or DirecShapeType.
 /// </summary>
 /// <param name="solid"></param>
 /// <returns></returns>
 public static bool ValidateGeometry(Solid solid)
 {
     return SolidValidator.IsValidGeometry(solid);
 }
开发者ID:whztt07,项目名称:RevitIFC,代码行数:9,代码来源:IFCGeometryUtil.cs



注:本文中的Solid类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SolidBrush类代码示例发布时间:2022-05-24
下一篇:
C# SoftFX类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap