Origin of planar face

Origin of planar face

phongthehuynh95
Contributor Contributor
3,393 Views
5 Replies
Message 1 of 6

Origin of planar face

phongthehuynh95
Contributor
Contributor

Hi,

I am trying to get curveloop from the element.

I have rectangular parallelepiped element, i want get the curveloop from the top face of it.

But when i access into the planar face i realized that: the origin of planar face's different from the origin of element. When i move the element wherever i want, planar face still be there. It makes me confused, i dont understand the different, it must be the same, right?

So i can neither move the face nor change origin. Do we have another way to get curveloop from face with the same element origin?

 

Appreciate for any comments.

Regards

askaboutface.jpgaskaboutface2.jpg

0 Likes
Accepted solutions (1)
3,394 Views
5 Replies
Replies (5)
Message 2 of 6

jeremytammik
Autodesk
Autodesk

What are you trying to achieve, and why?

 

I think an illustration would help understand better... even just a minimal hand-drawn sketch...

 



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

0 Likes
Message 3 of 6

FAIR59
Advisor
Advisor
Accepted solution

If the origin of the planar face doesn't move when you move the familyInstance, then the face belongs to the SymbolGeometry, and you need to apply a Transform ( == familyInstance.GetTransForm() ) to get the "world coordinates of the face.

You can use the  ExporterIFCUtils.UsesInstanceGeometry() method to check .

PlanarFace _face;
FamilyInstance inst =element as FamilyInstance;
if(   !ExporterIFCUtils.UsesInstanceGeometry(inst))
{
	Transform trans =inst.GetTransform();
	XYZ origin = trans.OfPoint( _face.Origin);
}
Message 4 of 6

phongthehuynh95
Contributor
Contributor

Thanks for your reply. Thats exactly whats im looking for.

Regards.

0 Likes
Message 5 of 6

Anonymous
Not applicable

Hi!

I am having the problem with getting the planar face to create a pipe connector.

 

ConnectorElement.CreatePipeConnector(doc, DomesticColdWater, PlanarFace)

What should I input there and how can I get a planar face? Could you please help with the code. I am using the RevitPythonShell for that. Thank you!

0 Likes
Message 6 of 6

jlpgy
Advocate
Advocate

Hi @Anonymous  :

I Copied the following from Revit API document:

public void CreatePipeConnectors(UIDocument uiDocument, Extrusion extrusion)
{
    // get the faces of the extrusion
    Options geoOptions = uiDocument.Document.Application.Create.NewGeometryOptions();
    geoOptions.View = uiDocument.Document.ActiveView;
    geoOptions.ComputeReferences = true;

    List<PlanarFace> planarFaces = new List<PlanarFace>();
    Autodesk.Revit.DB.GeometryElement geoElement = extrusion.get_Geometry(geoOptions);
    foreach (GeometryObject geoObject in geoElement)
    {
        Solid geoSolid = geoObject as Solid;
        if (null != geoSolid)
        {
            foreach (Face geoFace in geoSolid.Faces)
            {
                if (geoFace is PlanarFace)
                {
                    planarFaces.Add(geoFace as PlanarFace);
                }
            }
        }
    }

    if (planarFaces.Count > 1)
    {
        // Create the Supply Hydronic pipe connector
        //PipeConnector connSupply = 
        //    uiDocument.Document.FamilyCreate.NewPipeConnector(planarFaces[0].Reference, 
        //                                           PipeSystemType.SupplyHydronic);
        ConnectorElement connSupply =
            ConnectorElement.CreatePipeConnector(uiDocument.Document, PipeSystemType.SupplyHydronic, planarFaces[0].Reference);
        Parameter param = connSupply.get_Parameter(BuiltInParameter.CONNECTOR_RADIUS);
        param.Set(1.0); // 1' radius
        param = connSupply.get_Parameter(BuiltInParameter.RBS_PIPE_FLOW_DIRECTION_PARAM);
        param.Set(2);

        // Create the Return Hydronic pipe connector
        //PipeConnector connReturn =
        //    uiDocument.Document.FamilyCreate.NewPipeConnector(planarFaces[1].Reference,
        //                                           PipeSystemType.ReturnHydronic);
        ConnectorElement connReturn =
            ConnectorElement.CreatePipeConnector(uiDocument.Document, PipeSystemType.ReturnHydronic, planarFaces[1].Reference);
        param = connReturn.get_Parameter(BuiltInParameter.CONNECTOR_RADIUS);
        param.Set(0.5); // 6" radius
        param = connReturn.get_Parameter(BuiltInParameter.RBS_PIPE_FLOW_DIRECTION_PARAM);
        param.Set(1);
    }
}

 

Also the screen shot of the API document is also attached which I think should be easier to read.

2019-11-29_140553.png

 

Notice that the

ConnectorElement..::..CreatePipeConnector Method

works for Family Document, while this post is about working in Revit RVT document.

Luckily, they share almost the same tech to fetch a PlanarFace from Revit DB 🙂

单身狗;代码狗;健身狗;jolinpiggy@hotmail.com