Stream(ArrayList data, Face face) { data.Add(new Snoop.Data.ClassSeparator(typeof(Face))); data.Add(new Snoop.Data.Double("Area", face.Area)); ///TODO: Restore: data.Add(new Snoop.Data.Object("Material element", face.MaterialElement)); data.Add(new Snoop.Data.Bool("Is two-sided", face.IsTwoSided)); data.Add(new Snoop.Data.Enumerable("Edge loops", face.EdgeLoops)); data.Add(new Snoop.Data.Object("Triangulate", face.Triangulate())); data.Add(new Snoop.Data.Object("Reference", face.Reference)); ConicalFace conicalFace = face as ConicalFace; if (conicalFace != null) { Stream(data, conicalFace); return; } CylindricalFace cylFace = face as CylindricalFace; if (cylFace != null) { Stream(data, cylFace); return; } HermiteFace hermiteFace = face as HermiteFace; if (hermiteFace != null) { Stream(data, hermiteFace); return; } PlanarFace planarFace = face as PlanarFace; if (planarFace != null) { Stream(data, planarFace); return; } RevolvedFace revlFace = face as RevolvedFace; if (revlFace != null) { Stream(data, revlFace); return; } RuledFace ruledFace = face as RuledFace; if (ruledFace != null) { Stream(data, ruledFace); return; } }
Stream(ArrayList data, RevolvedFace face) { data.Add(new Snoop.Data.ClassSeparator(typeof(RevolvedFace))); data.Add(new Snoop.Data.Xyz("Origin", face.Origin)); data.Add(new Snoop.Data.Xyz("Axis", face.Axis)); data.Add(new Snoop.Data.Object("Curve", face.Curve)); }
private void SolidProcess(Solid geomSolid, UIDocument doc, Material materialElement) { try { int icount = 0; fr_Progress.SetProBarFace(geomSolid.Faces.Size); foreach (Face geomFace in geomSolid.Faces) { fr_Progress.AddValueProBarFace(++icount); RevolvedFace revolvedFace = geomFace as RevolvedFace; if (null != revolvedFace) { } ConicalFace conicalFace = geomFace as ConicalFace; if (null != conicalFace) { } CylindricalFace cylindricalFace = geomFace as CylindricalFace; if (null != cylindricalFace) { } HermiteFace hermiteFace = geomFace as HermiteFace; if (null != hermiteFace) { } RuledFace ruledFace = geomFace as RuledFace; if (null != ruledFace) { } if (null != geomFace.Reference) { } Material materialElementNew = materialElement; if (null != geomFace.MaterialElement) { materialElementNew = geomFace.MaterialElement as Material; } Mesh geomMesh = geomFace.Triangulate(); AddFaceMaterial(materialElementNew, doc); MeshProcess(geomMesh); TextureCoord(geomFace); } } catch (Exception e) { string message; // Exception rised, report it by revit error reporting mechanism. message = "SolidProcess fails for Reason:" + Environment.NewLine; File.AppendAllText(@"C:\CadFaster\Revit\ExeWriter_log.txt", message); message = e.ToString(); //File.AppendAllText(@"C:\CadFaster\Revit\ExeWriter_log.txt", message); //return Autodesk.Revit.UI.Result.Failed; } //End of SolidProcess }
public RevolvedFace FacemaxWrapedRevolFace(List <RevolvedFace> hermiteFaces) { RevolvedFace face = hermiteFaces.First(); foreach (RevolvedFace i in hermiteFaces) { if (i.Area > face.Area) { face = i; } } return(face); }
public double MinSpaceRevolFace(Document doc, FamilyInstance familyInstance, RevolvedFace face, XYZ point) { IList <XYZ> points = new List <XYZ>(); Transform transform = familyInstance.GetTransform(); foreach (EdgeArray item in face.EdgeLoops) { foreach (Edge item3 in item) { Curve curve = item3.AsCurve(); points.Add(curve.GetEndPoint(0)); points.Add(curve.GetEndPoint(1)); } } XYZ point1 = points.First(); XYZ point2 = points.Last(); XYZ point3 = new XYZ(); points.Remove(point1); points.Remove(point2); point3 = points.First(); foreach (var i in points) { if (point3.Z > i.Z) { point3 = i; } } Plane plane = Plane.CreateByThreePoints(transform.OfPoint(point1), transform.OfPoint(point2), transform.OfPoint(point3)); plane.SignedDistanceTo(point); SketchPlane skt = SketchPlane.Create(doc, plane); doc.ActiveView.SketchPlane = skt; return(plane.SignedDistanceTo(point)); }
Stream(RevolvedFace face) { StreamFaceGeoometry(face); }
private void Stream(ArrayList data, RevolvedFace face) { data.Add(new Snoop.Data.ClassSeparator(typeof(RevolvedFace))); data.Add(new Snoop.Data.Xyz("Origin", face.Origin)); data.Add(new Snoop.Data.Xyz("Axis", face.Axis)); data.Add(new Snoop.Data.Object("Curve", face.Curve)); }
public void CopyElementsFlatToWarped(Document doc, FamilyInstance familyInstance, ICollection <ElementId> elementIds, Selection sel) { ICollection <ElementId> newlist = new List <ElementId>(); CopyPasteOptions option = new CopyPasteOptions(); ElementtransformToCopy tr = new ElementtransformToCopy(); FamilyInstance flat = tr.GetFlat(doc, familyInstance); List <PlanarFace> list1 = FlFaces(flat); FamilyInstance warped = tr.GetWarped(doc, familyInstance); PlanarFace face1 = Facemax(list1); Element element1 = doc.GetElement(elementIds.First()); LocationPoint loc = element1.Location as LocationPoint; XYZ pointorg = loc.Point; //double minspace = MinSpacePlanarFace(doc, familyInstance, face1, pointorg); Transform transform = TransformFlatWapred(doc, flat, warped); //Solid solid1 = Solidhelper.AllSolids(flat).First(); //Solid solid2 = Solidhelper.AllSolids(warped).First(); //Transform transform1 = solid1.GetBoundingBox().Transform; //Transform transform2 = solid2.GetBoundingBox().Transform; //Transform transform = transform1.Inverse.Multiply(transform2); using (Transaction tran = new Transaction(doc, "copy")) { tran.Start(); FailureHandlingOptions options = tran.GetFailureHandlingOptions(); IgnoreProcess ignoreProcess = new IgnoreProcess(); options.SetClearAfterRollback(true); options.SetFailuresPreprocessor(ignoreProcess); tran.SetFailureHandlingOptions(options); try { newlist = ElementTransformUtils.CopyElements(doc, elementIds, doc, transform, option); Remove_product(doc, newlist); } catch (Exception) { } foreach (ElementId eleid in newlist) { Element ele = doc.GetElement(eleid); LocationPoint locele = ele.Location as LocationPoint; XYZ pointcon = locele.Point; List <HermiteFace> list2 = WarpedFace(warped); if (list2.Count != 0) { HermiteFace face2 = FacemaxWraped(list2); //double distanceloc = kcpointtoHemiteFace(face2, pointcon); double distanceloc = MinSpaceHermiteFace(doc, familyInstance, face2, pointcon); var xv1 = FIndpointonwraped(pointcon, new XYZ(0, 0, 1), distanceloc); XYZ point1 = pointcon - xv1; ElementTransformUtils.MoveElement(doc, eleid, point1); } else { List <RevolvedFace> revolvedFaces = WarpedFaceRevolFace(warped); RevolvedFace face2 = FacemaxWrapedRevolFace(revolvedFaces); //double distanceloc = kcpointtoHemiteFace(face2, pointcon); double distanceloc = MinSpaceRevolFace(doc, familyInstance, face2, pointcon); var xv1 = FIndpointonwraped(pointcon, new XYZ(0, 0, 1), distanceloc); XYZ point1 = pointcon - xv1; ElementTransformUtils.MoveElement(doc, eleid, point1); } //if (minspace > 0) //{ // var xv1 = FIndpointonwraped(pointcon,doc.ActiveView.UpDirection, distanceloc); // XYZ point1 = pointcon - xv1; // ElementTransformUtils.MoveElement(doc, eleid, point1); //} //else //{ // var xv1 = FIndpointonwraped(pointcon, doc.ActiveView.UpDirection, distanceloc); // XYZ point1 = xv1 - pointcon; // ElementTransformUtils.MoveElement(doc, eleid, point1); //} } tran.Commit(); } }
private void DataProcess(Solid geomSolid, GeometryInstance instance) { try { uint ufaces = 0; uint uVertices = 0; uint uPoints = 0; uint iStartId = (uint)d_VerticesList.Count; foreach (Face geomFace in geomSolid.Faces) { iStartId = (uint)d_VerticesList.Count; bool bNewFace = true; ufaces++; Mesh mesh = geomFace.Triangulate(); foreach (XYZ ii in mesh.Vertices) { uVertices++; XYZ point = ii; if (null != instance) { Transform instTransform = instance.Transform; XYZ transformedPoint = instTransform.OfPoint(point); } } uint iNextId = 0; for (int i = 0; i < mesh.NumTriangles; i++) { MeshTriangle triangle = mesh.get_Triangle(i); XYZ vertex = triangle.get_Vertex(0); if (bNewFace) { iNextId = iStartId / 3; bNewFace = false; } u_IndicesList.Add(3); AddVertex(iStartId, vertex, iNextId++); vertex = triangle.get_Vertex(1); AddVertex(iStartId, vertex, iNextId++); vertex = triangle.get_Vertex(2); AddVertex(iStartId, vertex, iNextId++); } XYZ origin = new XYZ(0, 0, 0); XYZ normal = new XYZ(0, 0, 0); XYZ vector = new XYZ(0, 0, 0); PlanarFace planarFace = geomFace as PlanarFace; if (null != planarFace) { origin = planarFace.Origin; normal = planarFace.Normal; vector = planarFace.get_Vector(0); } ConicalFace ConFace = geomFace as ConicalFace; if (null != ConFace) { origin = ConFace.Origin; normal = ConFace.Axis; vector = ConFace.get_Radius(0); } HermiteFace HermiteFace = geomFace as HermiteFace; if (null != HermiteFace) { origin = new XYZ(0, 0, 0); //HermiteFace.Points; normal = new XYZ(0, 0, 0); //HermiteFace.TaAxis; vector = new XYZ(0, 0, 0); //HermiteFace.get_Tangents(0); } RevolvedFace RevolFace = geomFace as RevolvedFace; if (null != RevolFace) { origin = RevolFace.Origin; normal = RevolFace.Axis; vector = RevolFace.get_Radius(0); } RuledFace RulFace = geomFace as RuledFace; if (null != RulFace) { origin = new XYZ(0, 0, 0); // RulFace.get_Point; normal = new XYZ(0, 0, 0); ///RulFace.Axis; vector = RulFace.get_Point(0); } CylindricalFace CylinFace = geomFace as CylindricalFace; if (null != CylinFace) { origin = CylinFace.Origin; normal = CylinFace.Axis; vector = CylinFace.get_Radius(0); } uint featuresCount = 0; for (int s = d_NormalsList.Count; s < d_VerticesList.Count; s += 3) { d_NormalsList.Add(normal.X); d_NormalsList.Add(normal.Y); d_NormalsList.Add(normal.Z); d_TextureCoordsList.Add(normal.X); d_TextureCoordsList.Add(normal.Y); d_TextureCoordsList.Add(normal.Z); featuresCount++; } u_FeaturesIndList.Add(featuresCount); } foreach (Edge edge in geomSolid.Edges) { foreach (XYZ ii in edge.Tessellate()) { uPoints++; XYZ point = ii; if (null != instance) { Transform instTransform = instance.Transform; XYZ transformedPoint = instTransform.OfPoint(point); } } }//foreach (Face geomFace in geomSolid.Faces) //string Osa = element.Name.ToString() + element.Id.ToString(); } catch (Exception e) { string message; // Exception rised, report it by revit error reporting mechanism. message = e.ToString(); File.AppendAllText(@"C:\CadFaster\Revit\ExeWriter_log.txt", message); //return Autodesk.Revit.UI.Result.Failed; } //End of DataProcess }
public virtual void Stream(RevolvedFace face) { StreamFaceGeoometry(face); }
public Surface FaceToSpeckle(RevolvedFace revolvedFace, double tolerance) { throw new NotImplementedException(); }
public virtual void Stream(RevolvedFace face) { StreamFaceGeometry(face); }