Create dimension for elements of linked model

Create dimension for elements of linked model

trinhnguyen060998
Explorer Explorer
695 Views
5 Replies
Message 1 of 6

Create dimension for elements of linked model

trinhnguyen060998
Explorer
Explorer

I want to create a dimension for the pipe of the linked model. In my code in case 1, it creates a symbolic detailLine to get a reference and then draw, meaning it will draw on the detailLine, not on the actual pipe that needs to be drawn. In case 2, if I use Face to get the reference, the problem occurs when I create the dimension, if I move the dimension, the original reference will be lost, leading to Revit taking an arbitrary different reference, then draw a different dimension than desired. Is there another way to get the pipe reference in a linked model? Please help me. Thank!

 

0 Likes
696 Views
5 Replies
Replies (5)
Message 2 of 6

Moustafa_K
Collaborator
Collaborator

To obtain the reference of the curve of the pipe and set its dimensions accordingly, you need to access the linked document containing the pipe. it would be good to read a bit of explanation and a practical demonstration over this post and this post. This involves working with linked references. The following steps will guide you through the process:

  1. Retrieve the linked pipe element.
  2. Obtain the RevitLinkInstance.
  3. Extract the geometry of the pipe.
  4. Access the first element, which typically represents the location curve reference. Note that this behavior is based on experience and may change in future Revit versions, so thorough testing is recommended.

see this example that demonstrate the above steps:

 

 

var linkedPipeReference = UiDoc.Selection.PickObject(ObjectType.PointOnElement);
var revitLinkInstance =
    Doc.GetElement(linkedPipeReference.ElementId) as RevitLinkInstance;
var linkedPipe = revitLinkInstance
    .GetLinkDocument()
    .GetElement(linkedPipeReference.LinkedElementId);

var op = new Options()
{
    DetailLevel = ViewDetailLevel.Undefined,
    IncludeNonVisibleObjects = true,
    ComputeReferences = true
};

var geo = linkedPipe.get_Geometry(op);
if (geo is null)
{
    // element Geometry can't be extracted
    return null;
}
List<Line> geoObjects = geo.OfType<Line>().ToList();

var instances = geo.OfType<GeometryInstance>();
foreach (var ins in instances)
{
    var geoIns = ins.GetSymbolGeometry();
    geoObjects.AddRange(geoIns.OfType<Line>());
}

var pipeCurveReference = geoObjects.FirstOrDefault()?.Reference;
if (pipeCurveReference != null && revitLinkInstance != null)
{
    pipeCurveReference = pipeCurve.CreateLinkReference(revitLinkInstance);
}

// now you can play with pipeCurveReference

 

 

 

see if this helps, and let us know your findings

Moustafa Khalil
Cropped-Sharp-Bim-500x125-Autodesk-1
0 Likes
Message 3 of 6

trinhnguyen060998
Explorer
Explorer

Hi @Moustafa_K, thank you for your support!
I followed your code and I got the geometry of the linked pipe. But there are no lines in that geometry, the list<Line> is empty. 

I knew that I could get the solid/faces from the geometry. However, I need to draw dimensions from the center of the pipe, I think face reference is not suitable for this case. 

Do you have any idea how to get the reference of linked elements for creating dimension?

0 Likes
Message 4 of 6

Moustafa_K
Collaborator
Collaborator

are you sure you set the options includeinvisible?

IncludeNonVisibleObjects = true,

 

Moustafa Khalil
Cropped-Sharp-Bim-500x125-Autodesk-1
0 Likes
Message 5 of 6

trinhnguyen060998
Explorer
Explorer

I made sure to add this option in.

0 Likes
Message 6 of 6

Moustafa_K
Collaborator
Collaborator

it would be interesting to know you have a pipe that doesn't have a curve reference...  can you put this pipe in a revit file and send it?

 

Moustafa Khalil
Cropped-Sharp-Bim-500x125-Autodesk-1
0 Likes