find position of Revit link

This widget could not be displayed.

find position of Revit link

Anonymous
Not applicable

I am trying to find the position of Linked Revit models in my Project. The locationPoint gives null and I couldnot

find the position.

 

    FilteredElementCollector collector = new FilteredElementCollector(myDoc);//
                collector.OfClass(typeof(Instance)).OfCategory(BuiltInCategory.OST_RvtLinks);//RevitLinkType
   

    foreach (Element elLink in collector)
                {
                    Instance ins = elLink as Instance;
                    RevitLinkType linkType = myDoc.GetElement(ins.GetTypeId()) as RevitLinkType;
                    LocationPoint pn = linkType.Location as LocationPoint;
                if (null != pn)
                {
                    TaskDialog.Show("rvt", "location " + pn.Point.X + "     " + pn.Point.Y + "    " + pn.Point.Z);
                }
            }
0 Likes
Reply
1,677 Views
3 Replies
Replies (3)

jeremytammik
Autodesk
Autodesk

Select your link in RevitLookup and explore its properties.

 

Does it have a Location property?

 

If so, you can access that through the API.

 



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

0 Likes

jeremytammik
Autodesk
Autodesk

I just noticed your identical question on StackOverflow and provided another answer there which may help further:

  

https://stackoverflow.com/questions/55556024/how-to-find-the-position-of-a-linked-revit-file

 

Look at The Building Coder discussion of Determining Host Document Location of a Linked Element:

 

`RevitLinkInstance` is derived from the `Instance` class, the base class for all instance objects. It provides the methods `GetTransform`, to retrieve the transform of the instance, and `GetTotalTransform` that includes the true north transform as well.

 

Cheers,

 

Jeremy

 

 



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

0 Likes

jeremytammik
Autodesk
Autodesk

oops, answered the wrong thread by mistake, please ignore, cannot delete answer, just edit...

 



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

0 Likes