Picking Regions (split faces)

Picking Regions (split faces)

juancalvoferrandiz
Enthusiast Enthusiast
1,754 Views
9 Replies
Message 1 of 10

Picking Regions (split faces)

juancalvoferrandiz
Enthusiast
Enthusiast

Hello everyone,

 

I'm trying to select regions of split faces as we can do with the paint tool with no positive result.

I use pickobject() method for selecting faces. 

http://www.revitapidocs.com/2018.1/0315fd62-b533-1817-2f2d-d9ebd4bc8e33.htm

 

With GetRegions() I get the list of regions, but I'm not able to neither use a pick system or idetify them by no criteria that is not area or material assignation properties.

http://www.revitapidocs.com/2018.1/9bde5f26-f830-7fca-39aa-792f9ac7caa5.htm

 

With FaceSplitter I'm not able to think in any option either.

http://www.revitapidocs.com/2018.1/ba55587f-4f1e-7f4c-5b1c-864e10cab304.htm

 

All comments are wellcome.

Thanks a lot.

 

Juan.

0 Likes
Accepted solutions (1)
1,755 Views
9 Replies
Replies (9)
Message 2 of 10

pmcmm1
Enthusiast
Enthusiast

Hi Juan,

 

You should be able to have the resulting faces with the GetRegions() command, but you will have to use the revit API to work with them I believe. It is rather limited the split faces commands in Revit API.

 

I am also struggling with a similar problem. I want to divide a wall automatically using facesplitters but I can't seem to find a way to create these elements using the revit API. Any idea?

 

Thanks.

Pedro

0 Likes
Message 3 of 10

Revitalizer
Advisor
Advisor
Accepted solution

Hi,

 

Reference reference = yourUIDocument.Selection.PickObject(ObjectType.PointOnElement);

if (reference != null)
{
    Element refElem = yourDocument.GetElement(reference.ElementId);
    PlanarFace planarFace = refElem.GetGeometryObjectFromReference(reference) as PlanarFace;
}

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 4 of 10

juancalvoferrandiz
Enthusiast
Enthusiast

Great. Thanks @Revitalizer. I didn't realize in the enum option PointOnElement:

 

http://www.revitapidocs.com/2015/2d0cbbba-d4ab-84b7-b081-36c14769d82c.htm

 

@pmcmm1, I hope this solves your problem aswell. If not, please tell me and I will see if I can help you in something.

 

Have a nice day.

0 Likes
Message 5 of 10

juancalvoferrandiz
Enthusiast
Enthusiast

Hi,

 

@Revitalizer, do you know how I can do the highlight selection with PointOnElement as with Face in ObjectType enum?

It seems  Face ObjectType has the highlight internally implemented while PointOnElement doesn't.

 

I'm trying around this point of view with no positive  results: https://thebuildingcoder.typepad.com/blog/2010/06/highlight-elements.html

 

Thanks. Cheers, Juan.

0 Likes
Message 6 of 10

Revitalizer
Advisor
Advisor

Hi,

 

for display purposes, I sometimes create new elements which I remove after use.

For example, after picking a point in a 2D view, I place a marker consisting of a circle and two lines forming an "x" inside it -just DetailCurves: "This is the point you've jst picked."

I a similar manner, you could create some sort of DirectShape to display a face element of arbitrary geometry.

This could be colorized (view overrides, material).

Since it resides at the same place as the original face, you should move it slightly outwards.

This proxy element is an element by itself, it can be highlighted.

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 7 of 10

pmcmm1
Enthusiast
Enthusiast

Hi there Juan,

 

Great to hear that your problem is fixed. My question is slightly different, I plan to create regions in the external walls by drawing Face Splitter lines in the facade, however I intend to have this done automatically.

 

I can't seem to find a way to create the FaceSplitter line automatically. I presume you are drawing them manually?

0 Likes
Message 8 of 10

juancalvoferrandiz
Enthusiast
Enthusiast

Thanks for your solution. Yes, after selection (PickObject operation), I do something similar but with the Namespace Analysis and a SpatialFieldPrimitive.

 

I like the idea with points, I didn't thought about it. Also maybe inserting a family that its an sphere during 3D work.

 

What I mean is during a multiple selection process. In summary:

 

If use ObjectType.Face: During selection the faces are highlighted, so I know which faces I'm selecting. Also an + or - symbol appears to know when I may be repeating selection. I can't select regions.

 

If use ObjectType.PointOnElement: The faces doesn't higlight during selection process. I don't know which elements I'm selecting until I finish the selection process. I may select two or more times the same face without knowing during selection process. I can select regions.

 

Thanks for your time.

0 Likes
Message 9 of 10

pmcmm1
Enthusiast
Enthusiast

In the past, I wrote a code that does the same job but it only requires you to select the wall element. With this code you dont have to use the PointOnElement to get the face, which gives you more flexibility.

 

    geomOption = app.Create.NewGeometryOptions()

    geomOption.ComputeReferences = True
    geomOption.DetailLevel = ViewDetailLevel.Fine
    geomOption.IncludeNonVisibleObjects = True

    face_dict = dict()

    for wall in walls:
        #code to get the walls from the selection
        geomElem = wall.get_Geometry(geomOption)
        face_dict[wall.Id.IntegerValue]=dict(geometry=geomElem,wall=wall)
        for geomSolid in geomElem:
        	#print geomSolid
        	#if (geomSolid):
            for geomFace in geomSolid.Faces:
                if geomFace.FaceNormal.IsAlmostEqualTo(wall.Orientation) == True:
                    face_dict[wall.Id.IntegerValue]['face']=geomFace
0 Likes
Message 10 of 10

canyon.des
Contributor
Contributor

 

 

 

 

 

    public class SurfaceSelectionFilter : ISelectionFilter
    {      
        public bool AllowElement(Element element)
        {
            return true;
        }
      
        public bool AllowReference(Reference refer, XYZ point)
        {
            if (refer.ElementReferenceType == ElementReferenceType.REFERENCE_TYPE_SURFACE)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
SurfaceSelectionFilter filter = new SurfaceSelectionFilter();
Reference reference = yourUIDocument.Selection.PickObject(ObjectType.PointOnElement, filter, "please select a Face");

 

 

Bruce Hans

 

 

 

0 Likes