create dimension between reference plane and element

create dimension between reference plane and element

Yonas89
Collaborator Collaborator
1,290 Views
4 Replies
Message 1 of 5

create dimension between reference plane and element

Yonas89
Collaborator
Collaborator

Hello  I am trying to create a linear dimension between top reference plane and element. In order to do that I need to add desired element's edge to referenceArray. However I don't know how to access this edge through api. Which property or method should I use to add this edge(red arrow in picture) to referenceArray.

ref.PNG

0 Likes
1,291 Views
4 Replies
Replies (4)
Message 2 of 5

JimJia
Alumni
Alumni

Dear Jonas Grazys, 

 

The NewDimension API accepts ReferenceArray as method parameter which consits of references, so you just need to build references array.

 

For ReferencePlane, we can get reference form ReferencePlane directly via ReferencePlane.GetReference().

 

If you want to access reference of element edge, you can get it from element geometry, some code snippet:

Options opt = new Options();
opt.ComputeReferences = true; // ensure to use true to return reference
foreach(var gobj in element.get_geometry(opt ))
{
    if(gob is Edge)
    {
          Reference edgeRef = (gobj as Edge).Reference; // access reference from edge
    }
}

You may need to refere to pages below on more related:
http://thebuildingcoder.typepad.com/blog/2015/05/how-to-retrieve-dimensioning-references.html
http://thebuildingcoder.typepad.com/blog/2009/10/revit-family-creation-api-labs.html

 

 


Jim Jia
Autodesk Forge Evangelist
https://forge.autodesk.com
Developer Technical Services
Autodesk Developer Network
Email: Jim.Jia@autodesk.com
0 Likes
Message 3 of 5

Yonas89
Collaborator
Collaborator

@JimJia,

thank you for your reply. I may haven't used the right terms in my question, cause I'm still relatively new to Revit. It's a swept profile and not a solid element, thus the term Edge, is not really good here. However I was able to solve this. I needed to use  get family instance of this element and use  "GetReferenceByName" method . In this particular example the name is "Right". It worked for me just fine. 

0 Likes
Message 4 of 5

LTusche1
Participant
Participant

Hello @JimJia,

when I append ReferencePlane.GetReference() to the ReferenceArray I just get the exception:
"The references are not geometric references."

 

Do you have an idea what could cause for this?
Maybe it has to do with the ReferenceType?
The Reference in the Dimension is REFERENCE_TYPE_SURFACE while the reference that you get from ReferencePlane.GetReference() is REFERENCE_TYPE_NONE.

LTusche1_0-1687359118642.png

 

Message 5 of 5

lo_t_tran
Explorer
Explorer

You need to call document.Regenerate(); after creating the ReferencePlane.

0 Likes