(Tessellated shape builder) cylindrical void in geometry issue

(Tessellated shape builder) cylindrical void in geometry issue

zrodgersTSSSU
Advocate Advocate
828 Views
2 Replies
Message 1 of 3

(Tessellated shape builder) cylindrical void in geometry issue

zrodgersTSSSU
Advocate
Advocate

Hey Everyone, I made a script a while ago that took wall geometry and recreated it on the slab for when doing tilt wall layout plans. Looks something like this...

zrodgersTSSSU_0-1628787282509.png

 

it allows us to easily create layout plans for our total stations. 

but there is an issue when i have a round penetration going though the wall. Like this....

 

zrodgersTSSSU_1-1628787440491.png

 

Here is my code:

 foreach (ElementId elemId in selectedIds)
                        {
                            

                            Element elem = uidoc.Document.GetElement(elemId);

                            double wVolume = 0;
                            double wArea = 0;
                            if ((BuiltInCategory)elem.Category.Id.IntegerValue == BuiltInCategory.OST_Walls)
                            {

                                //get wall area and volume
                                wVolume = elem.LookupParameter("Volume").AsDouble();
                                wArea = elem.LookupParameter("Area").AsDouble();

                                Options opts = new Options();
                                opts.ComputeReferences = true;
                                opts.IncludeNonVisibleObjects = false;

                                //geometry element
                                GeometryElement geoEle = elem.get_Geometry(opts);

                                DirectShape ds = null;
                                TessellatedShapeBuilder builder = new TessellatedShapeBuilder();
                                builder.OpenConnectedFaceSet(true);
                                
                                //get wall solids
                                foreach (GeometryObject geomObj in geoEle)
                                {
                                    Solid geomSolid = geomObj as Solid;
                                    if (null != geomSolid && 0 < geomSolid.Faces.Size)
                                    {
                                        int count = geomSolid.Faces.Size;
                                        foreach (Face face in geomSolid.Faces)
                                        {
                                            List<CurveLoop> cL = new List<CurveLoop>();

                                            cL = (List<CurveLoop>)face.GetEdgesAsCurveLoops();
                                            int countCl = cL.Count;
                                            foreach(CurveLoop curveLoop in cL)
                                            {
                                                List<XYZ> args = new List<XYZ>();
                                                foreach (Curve curve in curveLoop)
                                                {
                                                    XYZ pt = curve.GetEndPoint(0);
                                                    args.Add(pt);
                                                }
                                                builder.AddFace(new TessellatedFace(args, ElementId.InvalidElementId));
                                                args.Clear();
                                            }

                                        }

                                    }
                                }

                                builder.CloseConnectedFaceSet();
                                builder.Build();
                                TessellatedShapeBuilderResult result = builder.GetBuildResult();

                                //create direct shape
                                ds = DirectShape.CreateElement(doc, new ElementId(BuiltInCategory.OST_Walls));
                                ds.ApplicationId = "Application id";
                                ds.ApplicationDataId = "Geometry object id";
                                ds.SetShape(result.GetGeometricalObjects());

 

any idea how i can make this work with a cylindrical penetration?

heres the error im getting.

zrodgersTSSSU_2-1628787728965.png

 

 

0 Likes
Accepted solutions (1)
829 Views
2 Replies
Replies (2)
Message 2 of 3

zrodgersTSSSU
Advocate
Advocate
Accepted solution

I actually figured this out but not through the api. I modified the family so that it used a sweep of a rectangular profile.

zrodgersTSSSU_0-1628789841452.png

 

then set the trajectory segmentation to 10 degrees.

 

this lets the tessellated shape builder create its faces without error. 

 

zrodgersTSSSU_1-1628789976298.png

 

 

 

but... if someone knows how to fix this issue through the api please let me know.

 

0 Likes
Message 3 of 3

AGGilliam
Collaborator
Collaborator

I'm assuming the cylinder was originally created by extruding a circle? In that case, the circular face would only have 2 points (2 connected curves) which isn't enough to create a tessellated face. The only workaround I could think of, other than what you've already done, would be to check for when args.Count is 2 and calculate the other various points you want to use for the face then pass that list of points instead. More of an idea than a guaranteed fix really. Although, your solution seems to be working perfectly.