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: 

Create Dimension: Get references to FamilyInstances

20 REPLIES 20
Reply
Message 1 of 21
michael
4117 Views, 20 Replies

Create Dimension: Get references to FamilyInstances

michael
Participant
Participant

Hello,

 

I’m trying to programmatically place a dimension on some family Instances in a section view. Let’s assume, that I have some rectangular boxes placed in a wall. The Insertion point of such a box is in its centre.

I want to place a dimension with references to the origins of each box. I know that I can place a dimension using the “doc.Create.NewDimension” method. But I don’t know how to get the correct reference to the centre of the box. When I place the dimensions manually in the Revit model, I can select the reference planes of the centre of the box, but how do I get them using the API?

 

Any help would be appreciated!

0 Likes

Create Dimension: Get references to FamilyInstances

Hello,

 

I’m trying to programmatically place a dimension on some family Instances in a section view. Let’s assume, that I have some rectangular boxes placed in a wall. The Insertion point of such a box is in its centre.

I want to place a dimension with references to the origins of each box. I know that I can place a dimension using the “doc.Create.NewDimension” method. But I don’t know how to get the correct reference to the centre of the box. When I place the dimensions manually in the Revit model, I can select the reference planes of the centre of the box, but how do I get them using the API?

 

Any help would be appreciated!

20 REPLIES 20
Message 2 of 21
Anonymous
in reply to: michael

Anonymous
Not applicable

I currently have a need for this functionality also. I've been investigating this and the best I can do so far is to read the references from a dimension added manually in the project from the UI and then use those references to create a new dimension. The UI calls these Shape Handle References but I am unable to find a similar concept within the API.

In an attempt to determine how to get at the family's reference planes from the project I have been extracting anything I can find that contains a reference and dumping the output of Reference.ConvertToStableRepresentation() to see if I can find a match against the references I am reading from the manual dimension.

lets say the stable representations for my dimension references looks like this:

 

66a421da-90cb-4df2-8efe-c312e4f78aa0-0003d32b:0:INSTANCE:a2177cbb-03d8-4416-a4d8-8ada6fc0165a-0003ebf0:0:SURFACE
66a421da-90cb-4df2-8efe-c312e4f78aa0-0003d32b:0:INSTANCE:a2177cbb-03d8-4416-a4d8-8ada6fc0165a-0003ebf0:2:SURFACE

 I then dump out the same data for any surfaces I can find in the family and get this:

 

66a421da-90cb-4df2-8efe-c312e4f78aa0-0003d32b:0:INSTANCE:a2177cbb-03d8-4416-a4d8-8ada6fc0165a-0003ebf0:78:SURFACE
66a421da-90cb-4df2-8efe-c312e4f78aa0-0003d32b:0:INSTANCE:a2177cbb-03d8-4416-a4d8-8ada6fc0165a-0003ebf0:83:SURFACE
66a421da-90cb-4df2-8efe-c312e4f78aa0-0003d32b:0:INSTANCE:a2177cbb-03d8-4416-a4d8-8ada6fc0165a-0003ebf0:88:SURFACE
66a421da-90cb-4df2-8efe-c312e4f78aa0-0003d32b:0:INSTANCE:a2177cbb-03d8-4416-a4d8-8ada6fc0165a-0003ebf0:91:SURFACE
66a421da-90cb-4df2-8efe-c312e4f78aa0-0003d32b:0:INSTANCE:a2177cbb-03d8-4416-a4d8-8ada6fc0165a-0003ebf0:93:SURFACE
66a421da-90cb-4df2-8efe-c312e4f78aa0-0003d32b:0:INSTANCE:a2177cbb-03d8-4416-a4d8-8ada6fc0165a-0003ebf0:95:SURFACE

 

As you can see they match up until what looks to be an index into the family's geometry table just before the reference type designation. I have no idea whether it is even possible to get at the family's reference planes from the project, so far I haven't found them other than by using the above method which is not even close to ideal.

My next step will be to build up a custom stable representation string using any old reference found within the family instance (using the symbol geometry of course) and replace the index value with the correct index (0 and 2 in my case). I will then hopefully convert this into a usable reference using Reference.ParseFromStableRepresentation(). As far as I can tell the index values are similar to ElementIds in that they are stable and unique to the particular document. The code will be directly tied to a particular family though but it's a start and might just get me out of trouble.

Hopefully there's an API supported way to get at these shape handle references and I'm just missing something, as what I'm about to do is an abominable hack to be sure.

Can anyone save me before it's too late?

 

 

I currently have a need for this functionality also. I've been investigating this and the best I can do so far is to read the references from a dimension added manually in the project from the UI and then use those references to create a new dimension. The UI calls these Shape Handle References but I am unable to find a similar concept within the API.

In an attempt to determine how to get at the family's reference planes from the project I have been extracting anything I can find that contains a reference and dumping the output of Reference.ConvertToStableRepresentation() to see if I can find a match against the references I am reading from the manual dimension.

lets say the stable representations for my dimension references looks like this:

 

66a421da-90cb-4df2-8efe-c312e4f78aa0-0003d32b:0:INSTANCE:a2177cbb-03d8-4416-a4d8-8ada6fc0165a-0003ebf0:0:SURFACE
66a421da-90cb-4df2-8efe-c312e4f78aa0-0003d32b:0:INSTANCE:a2177cbb-03d8-4416-a4d8-8ada6fc0165a-0003ebf0:2:SURFACE

 I then dump out the same data for any surfaces I can find in the family and get this:

 

66a421da-90cb-4df2-8efe-c312e4f78aa0-0003d32b:0:INSTANCE:a2177cbb-03d8-4416-a4d8-8ada6fc0165a-0003ebf0:78:SURFACE
66a421da-90cb-4df2-8efe-c312e4f78aa0-0003d32b:0:INSTANCE:a2177cbb-03d8-4416-a4d8-8ada6fc0165a-0003ebf0:83:SURFACE
66a421da-90cb-4df2-8efe-c312e4f78aa0-0003d32b:0:INSTANCE:a2177cbb-03d8-4416-a4d8-8ada6fc0165a-0003ebf0:88:SURFACE
66a421da-90cb-4df2-8efe-c312e4f78aa0-0003d32b:0:INSTANCE:a2177cbb-03d8-4416-a4d8-8ada6fc0165a-0003ebf0:91:SURFACE
66a421da-90cb-4df2-8efe-c312e4f78aa0-0003d32b:0:INSTANCE:a2177cbb-03d8-4416-a4d8-8ada6fc0165a-0003ebf0:93:SURFACE
66a421da-90cb-4df2-8efe-c312e4f78aa0-0003d32b:0:INSTANCE:a2177cbb-03d8-4416-a4d8-8ada6fc0165a-0003ebf0:95:SURFACE

 

As you can see they match up until what looks to be an index into the family's geometry table just before the reference type designation. I have no idea whether it is even possible to get at the family's reference planes from the project, so far I haven't found them other than by using the above method which is not even close to ideal.

My next step will be to build up a custom stable representation string using any old reference found within the family instance (using the symbol geometry of course) and replace the index value with the correct index (0 and 2 in my case). I will then hopefully convert this into a usable reference using Reference.ParseFromStableRepresentation(). As far as I can tell the index values are similar to ElementIds in that they are stable and unique to the particular document. The code will be directly tied to a particular family though but it's a start and might just get me out of trouble.

Hopefully there's an API supported way to get at these shape handle references and I'm just missing something, as what I'm about to do is an abominable hack to be sure.

Can anyone save me before it's too late?

 

 

Message 3 of 21
Anonymous
in reply to: Anonymous

Anonymous
Not applicable

A quick update to say that the above technique was successful, it's not pretty but it works. Just have to do the homework first to find out the index of the reference you want and then you can reliably create the same reference for any instance of that family.

0 Likes

A quick update to say that the above technique was successful, it's not pretty but it works. Just have to do the homework first to find out the index of the reference you want and then you can reliably create the same reference for any instance of that family.

Message 4 of 21
michael
in reply to: michael

michael
Participant
Participant

Thanks Scott,

 

I've tried your method and well, it works (I would never hed thought of this hack). Unfortunately the indices change from family to family (I’ve tested it with some families and I have some 0, 1, 2 and 4). But at least they seem to be stable for each family. I loaded my families into different documents, restarted Revit (and even Windows), and the indices stay the same (I haven’t tried worksharing).

 

As you say it would be much better to have an API supported way to obtain these references, as one can only hope that the indices of a family never change.

0 Likes

Thanks Scott,

 

I've tried your method and well, it works (I would never hed thought of this hack). Unfortunately the indices change from family to family (I’ve tested it with some families and I have some 0, 1, 2 and 4). But at least they seem to be stable for each family. I loaded my families into different documents, restarted Revit (and even Windows), and the indices stay the same (I haven’t tried worksharing).

 

As you say it would be much better to have an API supported way to obtain these references, as one can only hope that the indices of a family never change.

Message 5 of 21
Anonymous
in reply to: michael

Anonymous
Not applicable

Excellent, glad you've got it working. Wasn't sure if anyone could understand my ramblings 🙂

0 Likes

Excellent, glad you've got it working. Wasn't sure if anyone could understand my ramblings 🙂

Message 6 of 21
gopinath.taget
in reply to: michael

gopinath.taget
Alumni
Alumni

Hello,

 

I have enquired with the engineering team if there is an API to determine the shape handles for family instance. I will get back to you as soon as I learn something useful.

 

Thanks,

Gopinath

0 Likes

Hello,

 

I have enquired with the engineering team if there is an API to determine the shape handles for family instance. I will get back to you as soon as I learn something useful.

 

Thanks,

Gopinath

Message 7 of 21
Anonymous
in reply to: michael

Anonymous
Not applicable

I still do not understand what you did, could you help me?

0 Likes

I still do not understand what you did, could you help me?

Message 8 of 21
Anonymous
in reply to: Anonymous

Anonymous
Not applicable

Hello,

 

I do not have good news. There is no API to get the references you want (sorry). I have logged a change request with the engineering team and sent you the details.

 

Thanks

Gopinath

0 Likes

Hello,

 

I do not have good news. There is no API to get the references you want (sorry). I have logged a change request with the engineering team and sent you the details.

 

Thanks

Gopinath

Message 9 of 21
Anonymous
in reply to: Anonymous

Anonymous
Not applicable

Thanks for looking into this. Does the change request you submitted include a method to find the family references by name? Because that would be super awesome!

0 Likes

Thanks for looking into this. Does the change request you submitted include a method to find the family references by name? Because that would be super awesome!

Message 10 of 21
Anonymous
in reply to: Anonymous

Anonymous
Not applicable

Hello,

 

Can you please expand on this request? You want to reference the family instance? or the shape handles? If shape handles, you want to reference them by name?

 

Thanks

Gopinath

0 Likes

Hello,

 

Can you please expand on this request? You want to reference the family instance? or the shape handles? If shape handles, you want to reference them by name?

 

Thanks

Gopinath

Message 11 of 21
Anonymous
in reply to: Anonymous

Anonymous
Not applicable

How I'd wish this was implemented would be that any reference that has its "Is Reference" property set to anything except "Not a Reference" in the family editor would be included within the GeometryElement returned by GetSymbolGeometry.
The included object would have a base type of "GeometryReference" or similar (to hold any of the objects matching the above criteria) with any of the references that also provide the UI shape handles deriving from this class as an object of type "ShapeHandle" or similar.

 

The "GeometryReference" class should include the following information as a minimum:

 

  • A property labelled "Reference" which provides a stable reference to the object in the same way that is provided by other existing objects such as Face and Curve (likely inherited from GeometryObject anyway)
  • A property labelled "Name" which contains the string value of the name given to the reference in the family editor
  • An property labelled "GeometryReferenceType" or similar, containing the enumerated value corresponding to the drop-down list labelled "Is Reference" in the family editor (StrongReference, CenterLeftRight, etc.)
  • Lastly, a method or property labelled "GetGeometry" or similar that provides access to the position and orientation of the family reference, such as an attached ReferencePlane / Face / Curve element or whatever the actual underlying type of these things is according to the project document

Other properties of reference set within the family editor are probably a good idea to include also (Defines Origin, etc.).

 

In addition to the above, the following method added to the FamilyInstance class would be a great platform to work from:

 

public Reference FamilyInstance.GetGeometryReference(String referenceName) (return null if not found)
will return the reference to the "GeometryReference" object matching the name string, this could then be passed back into GetGeometryObjectFromReference to get the actual object.

0 Likes

How I'd wish this was implemented would be that any reference that has its "Is Reference" property set to anything except "Not a Reference" in the family editor would be included within the GeometryElement returned by GetSymbolGeometry.
The included object would have a base type of "GeometryReference" or similar (to hold any of the objects matching the above criteria) with any of the references that also provide the UI shape handles deriving from this class as an object of type "ShapeHandle" or similar.

 

The "GeometryReference" class should include the following information as a minimum:

 

  • A property labelled "Reference" which provides a stable reference to the object in the same way that is provided by other existing objects such as Face and Curve (likely inherited from GeometryObject anyway)
  • A property labelled "Name" which contains the string value of the name given to the reference in the family editor
  • An property labelled "GeometryReferenceType" or similar, containing the enumerated value corresponding to the drop-down list labelled "Is Reference" in the family editor (StrongReference, CenterLeftRight, etc.)
  • Lastly, a method or property labelled "GetGeometry" or similar that provides access to the position and orientation of the family reference, such as an attached ReferencePlane / Face / Curve element or whatever the actual underlying type of these things is according to the project document

Other properties of reference set within the family editor are probably a good idea to include also (Defines Origin, etc.).

 

In addition to the above, the following method added to the FamilyInstance class would be a great platform to work from:

 

public Reference FamilyInstance.GetGeometryReference(String referenceName) (return null if not found)
will return the reference to the "GeometryReference" object matching the name string, this could then be passed back into GetGeometryObjectFromReference to get the actual object.

Message 12 of 21
gopinath.taget
in reply to: Anonymous

gopinath.taget
Alumni
Alumni

Hello,

 

I have added your comments to a new enhancement request and emailed you separately.

 

Cheers

Gopinath

0 Likes

Hello,

 

I have added your comments to a new enhancement request and emailed you separately.

 

Cheers

Gopinath

Message 13 of 21
michael
in reply to: gopinath.taget

michael
Participant
Participant

Thanks, this would be very helpfull Smiley Happy

0 Likes

Thanks, this would be very helpfull Smiley Happy

Message 14 of 21
gopinath.taget
in reply to: michael

gopinath.taget
Alumni
Alumni

Hello,

 

If there is nothing else, please go ahead and accept solution so we can close the ADN request as well.

 

Best Regards

Gopinath

0 Likes

Hello,

 

If there is nothing else, please go ahead and accept solution so we can close the ADN request as well.

 

Best Regards

Gopinath

Message 15 of 21
Anonymous
in reply to: gopinath.taget

Anonymous
Not applicable
This seems like an excellent request. It's not always that the physical geometry of the family is interesting for dimensioning (in particular) and to be able to find references to the defines origin reference planes would definitely help a lot.

Is there any update on this request? (I hope 1.5 years isn't too soon to ask ;))
0 Likes

This seems like an excellent request. It's not always that the physical geometry of the family is interesting for dimensioning (in particular) and to be able to find references to the defines origin reference planes would definitely help a lot.

Is there any update on this request? (I hope 1.5 years isn't too soon to ask ;))
Message 16 of 21
Anonymous
in reply to: Anonymous

Anonymous
Not applicable
2 1/4 years, is that too soon then? 😉
0 Likes

2 1/4 years, is that too soon then? 😉
Message 17 of 21
Dale.Bartlett
in reply to: Anonymous

Dale.Bartlett
Collaborator
Collaborator

Impatience will not help...




______________
Yes, I'm Satoshi.
0 Likes

Impatience will not help...




______________
Yes, I'm Satoshi.
Message 18 of 21
Anonymous
in reply to: Dale.Bartlett

Anonymous
Not applicable

I found this thread roughly ten minutes before making the post, and I found my need for this wishlist item about fifteen before that. If I posted that out of impatience, it would indeed be a serious personal problem.

 

Mentioning the time that has passed was not impatience. It was a defense of myself for bumping Ken's request for an update.

 

It's understandable that there will be triage at Autodesk, and that some wishlist items will take years. Is it also alright for us to ask for updates on items if a significant amount of time passes? I would think this would also be beneficial since it could help Autodesk to understand if some items are highly sought after.

 

Ken's request for an update had no response since February. It's reasonable to assume that the question was not going to be answered if it were left as it was.

 

If this functionality is coming in one or two upcoming versions of Revit, that's going to change several things for myself, and I assume others too. Out of curiosity, what was the correct course of action?

 

0 Likes

I found this thread roughly ten minutes before making the post, and I found my need for this wishlist item about fifteen before that. If I posted that out of impatience, it would indeed be a serious personal problem.

 

Mentioning the time that has passed was not impatience. It was a defense of myself for bumping Ken's request for an update.

 

It's understandable that there will be triage at Autodesk, and that some wishlist items will take years. Is it also alright for us to ask for updates on items if a significant amount of time passes? I would think this would also be beneficial since it could help Autodesk to understand if some items are highly sought after.

 

Ken's request for an update had no response since February. It's reasonable to assume that the question was not going to be answered if it were left as it was.

 

If this functionality is coming in one or two upcoming versions of Revit, that's going to change several things for myself, and I assume others too. Out of curiosity, what was the correct course of action?

 

Message 19 of 21
Dale.Bartlett
in reply to: Anonymous

Dale.Bartlett
Collaborator
Collaborator

Apologies, I was attempting irony. I really need to use more smiley faces...    




______________
Yes, I'm Satoshi.
0 Likes

Apologies, I was attempting irony. I really need to use more smiley faces...    




______________
Yes, I'm Satoshi.
Message 20 of 21
Anonymous
in reply to: Dale.Bartlett

Anonymous
Not applicable

I totally got it Dale.  😉

 

maybe that just exposes me for one of the beleaguered...

 

I can't put my project off any longer so will probably be using the vodoo and see if I can make it happen.

 

0 Likes

I totally got it Dale.  😉

 

maybe that just exposes me for one of the beleaguered...

 

I can't put my project off any longer so will probably be using the vodoo and see if I can make it happen.

 

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

Post to forums  

Autodesk Design & Make Report