Dimension of element Revit links move wrong location or throw error

ttnhan1
Contributor
Contributor

Dimension of element Revit links move wrong location or throw error

ttnhan1
Contributor
Contributor

Hi, I'm developing an add-in for Revit,

I wanna creating dimension for both main model and link model, create dimension for element in main model is ok but when create for link model by using mainDoc.Create.NewDimension(mainDoc.ActiveView, topLine, verArr) it throw null exception verArr. verArr = refer.CreateLinkReference(linkIntance).

ttnhan1_0-1718251519618.png

The blue color is link model

 

I used face and GeometryElement and used some function and it can pass and create dimension for link model, but when I move dimension, it 's went to a wrong location

 

ttnhan1_2-1718252092245.png

Create dimension

ttnhan1_3-1718252111994.png

When move dimension, they go to wrong place and change direction

I use dim.Segments.get_Item(i).TextPosition with dim is type dimension which I save from return of "mainDoc.Create.NewDimension(mainDoc.ActiveView, topLine, verArr)"

 

Code:

...

Dimension topDim;

List<Dimension> newDimension = new List<Dimension>();

...

topDim = mainDoc.Create.NewDimension(mainDoc.ActiveView, topLine, verArr);

newDimension.add(topDim );

 

Then,

foreach(Dimension dim in newDimension){

 //move dimension here

dim.Segments.get_Item(m).TextPosition = .....

}

I think the reference of link file is change or gone after created dimension

So how to move the dimension of element of link model on main model without change direction and move to wrong location or another element? Also, do we have any different way to create dimension for link model without use Face and GeometryElement, Solid?

0 Likes
Reply
421 Views
5 Replies
Replies (5)

jeremy_tammik
Autodesk
Autodesk

Can you achieve what you need when working manually in the end user interface? The first thing to verify is that your desired solution can be achieved at all and follows best practices. That is easiest in the UI.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes

ttnhan1
Contributor
Contributor

I'm making an auto tool, I need create dimension for all element like pipe...(both main model and link model). Currently, I can create dimension for link model but it is went to wrong place and wrong point when I move it

0 Likes

jeremy_tammik
Autodesk
Autodesk

Yes, I understand. Thank you for clarifying. This is absolutely the right place for all Revit .NET API questions. 

  

Still, I am asking you whether your desired dimensioning work as expected when you set it up and drive it manually through the end user interface.

   

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes

ttnhan1
Contributor
Contributor

yes, When use annotate -> aligned or any measuring tool of Revit, it's ok to move dimension of element of link model (work as expected).

But if use Revit API to set it up and drive it manually through the end user interface => it's went to wrong place (not work as expected)

0 Likes

TripleM-Dev.net
Advisor
Advisor

Hi @ttnhan1,

 

Use RevitLookup and inspect the References in the Dimension, and closely inspect the ConvertToStableRepresentation value of each.

 

Compare these between the following dimension to the identical element:

A. Dimension created in the UI

B. the First with the API created dimension

C. the API created dimension after it flipped to another location when trying to move a text

 

A thing to remember with links is that thay don't necessary have the same orientation or rotation for that matter.

The link can be moved or rotated relative to the host model internal origin.

 

- Michel

 

Ps. Also search the forum for "Dim StableReference" or a combo of it, sure it will turn up some posts.

0 Likes