Get planarface under element

Get planarface under element

mr.engineer.aec
Advocate Advocate
2,397 Views
10 Replies
Message 1 of 11

Get planarface under element

mr.engineer.aec
Advocate
Advocate

 Hi guys,

I want to get under planarface of pile cap.

Is there any method to get it from solid?

i can only get all planarface from solid 😞

Thank in advanced.

 

Screenshot_1.png

 

0 Likes
Accepted solutions (2)
2,398 Views
10 Replies
Replies (10)
Message 2 of 11

jeremytammik
Autodesk
Autodesk
Accepted solution

Yes, of course. 

 

It is very simple.

 

You say you know how to retrieve all the planar surfaces. 

 

Well, then you can iterate over them and ignore all that are not horizontal, e.g., by applying a predicate method like this to the planar surface normal:

 

    public static bool IsVertical( XYZ v )
    {
      return IsZero( v.X ) && IsZero( v.Y );
    }

 

https://github.com/jeremytammik/the_building_coder_samples/blob/master/BuildingCoder/BuildingCoder/U...

 

Next, you can sort the remaining horizontal planar surfaces by the Z coordinate of their Origin property:

 

https://www.revitapidocs.com/2020/9671f9cf-6779-d6ca-8af4-91ac44b986ac.htm

 

The one with the lowest Z coordinate is presumably the one you are after.

 

 

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 11

mr.engineer.aec
Advocate
Advocate

 Hi @jeremytammik 

Thank for your reply.

I am still finding workarounds according to your instructions.

Hope you can help me next time.

0 Likes
Message 4 of 11

jeremytammik
Autodesk
Autodesk

Thank you for your appreciation. My pleasure entirely.

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 5 of 11

mr.engineer.aec
Advocate
Advocate

 Hi @jeremytammik 

I solved my issue by your guide.
Now, i have new issue, hope you can help me.

I want to create floor from edgeloops of bottom face.

I get edgeloops but i can't curvearray to use create floor method.
How to get curvearray of bottom face ?
Thank in advance

               EdgeArrayArray curveloop = planarFace.EdgeLoops;
              //Floor newfloor = doc.Create.NewFloor(curveloop, true);
0 Likes
Message 6 of 11

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @mr.engineer.aec ,

try using the below code

 

Use GetEdgesAsCurveLoops() method 

                Face f;               
                IList<CurveLoop> curveLoops = f.GetEdgesAsCurveLoops() as IList<CurveLoop>;
                CurveArray CA = new CurveArray();
                foreach(CurveLoop CL in curveLoops)
                {
                    CurveLoopIterator CLi = CL.GetCurveLoopIterator();
                    while(CLi.MoveNext())
                    {
                        CA.Append(CLi.Current);
                    }
                }

I hope this helps.


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Message 7 of 11

mr.engineer.aec
Advocate
Advocate

 Hi @naveen.kumar.t 

thank for your reply.

I write code like you but after run, Bug is visible.
Can you hekp me to solve this issue ?
Many thanks

 

Screenshot_1.png

IList<CurveLoop> curveloop = planarFace.GetEdgesAsCurveLoops() as IList<CurveLoop>;
                                CurveArray curveArray = new CurveArray();
                                foreach(CurveLoop cl in curveloop)
                                {
                                    CurveLoopIterator cli = cl.GetCurveLoopIterator();
                                    while (cli.MoveNext())
                                    {
                                        curveArray.Append(cli.Current);
                                    }
                                    Floor newfloor = doc.Create.NewFloor(curveArray, true);
                                }
0 Likes
Message 8 of 11

naveen.kumar.t
Autodesk Support
Autodesk Support
Accepted solution

Hi @mr.engineer.aec ,

The error shows with the curves you have , you can't create a floor. can you check whether you got the proper face curve array?

The face curves should help you to construct a floor.

check whether the curves are valid.

 


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Message 9 of 11

mr.engineer.aec
Advocate
Advocate

 Thank @naveen.kumar.t 

this is my bad. I solved.

0 Likes
Message 10 of 11

Revitalizer
Advisor
Advisor

Hi,


the input curves are not sorted.


RevitAPI.chm says:

"[...]Face.GetEdgesAsCurveLoops

Orientations of the curves and curve loops match the orientations of the face's edges and edge loops. The order of the CurveLoops should be considered as arbitrary.[...]"

 

Edit:

Oops, seems that I didn't read it carefully.

Curves in CureLoops are sorted, returned CurveLoops List is not.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 11 of 11

mr.engineer.aec
Advocate
Advocate

 Hi @naveen.kumar.t 

Is there any way to offset curve to create floor like under picture. inside red line is curve get from face as above.

I search CreateViaOffset Method, but i don't know how to use it yet.

Can you show me how to use this method ?
Thank in advanced

 

Screenshot_2.png

0 Likes