Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

using reference Can't get edge of Cable Tray

1 REPLY 1
SOLVED
Reply
Message 1 of 2
NGM_AiYo
234 Views, 1 Reply

using reference Can't get edge of Cable Tray

I want to select an edge on cable tray. But the reference I got from the Selection.PickObject() can't get anything.

But it works on Pipe.

Reference pickObj = sel.PickObject(ObjectType.Edge);
                    Log.Info("side align " + AlignSide.Id + "  " + AlignSide.UniqueId);
                    
                    try
                    {
                        
                        GeometryObject go = AlignSide.GetGeometryObjectFromReference(pickObj) as GeometryObject;
                        if ( go is null)
                        {
                            Log.Info("geometry is null");
                            Options options = new Options();
                            options.ComputeReferences = true;
                            options.DetailLevel = ViewDetailLevel.Fine;
                            GeometryElement ge = AlignSide.get_Geometry(options);
                            foreach (GeometryObject item in ge)
                            {
                                if (item is Solid solid)
                                {
                                    foreach(Edge edg in solid.Edges)
                                    {
                                        Log.Info(edg.Reference.ConvertToStableRepresentation(doc));
                                    }
                                }
                            }

                        }
                        Edge edge = go as Edge;
                        Log.Info( "picked reference: " + pickObj.ConvertToStableRepresentation(doc));
                        if (edge == null)
                        {
                            Log.Info("edge is null");
                        }
                        Element element = doc.GetElement(pickObj.ElementId);
                        Line sideLine;
                        sideLine = edge.AsCurve() as Line;
                       
                    }
                    catch (Exception ex)
                    {
                        
                    }

 I print  all the references of cable Tray. and last reference is from pickObject().

16cc5331-08cb-404f-bc36-bec6c55aac53-004c8655:4:LINEAR
 16cc5331-08cb-404f-bc36-bec6c55aac53-004c8655:7:LINEAR
16cc5331-08cb-404f-bc36-bec6c55aac53-004c8655:11:LINEAR
 16cc5331-08cb-404f-bc36-bec6c55aac53-004c8655:15:LINEAR
16cc5331-08cb-404f-bc36-bec6c55aac53-004c8655:16:LINEAR
 16cc5331-08cb-404f-bc36-bec6c55aac53-004c8655:12:LINEAR
16cc5331-08cb-404f-bc36-bec6c55aac53-004c8655:8:LINEAR
16cc5331-08cb-404f-bc36-bec6c55aac53-004c8655:5:LINEAR
 16cc5331-08cb-404f-bc36-bec6c55aac53-004c8655:18:LINEAR
16cc5331-08cb-404f-bc36-bec6c55aac53-004c8655:9:LINEAR
16cc5331-08cb-404f-bc36-bec6c55aac53-004c8655:13:LINEAR
 16cc5331-08cb-404f-bc36-bec6c55aac53-004c8655:17:LINEAR
picked reference: 16cc5331-08cb-404f-bc36-bec6c55aac53-004c8655:3022:LINEAR

 

Is there any way to get edge of cable tray from PickObject(). 

My revit version is 2019.

1 REPLY 1
Message 2 of 2
RPTHOMAS108
in reply to: NGM_AiYo

If you switch to coarse detail level you can select such edges. Otherwise you can select a point on a face then find the distance of that point to each curve in order to select the edge.

 

Not sure why you can't get the reference in fine detail view.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


Autodesk Design & Make Report