GetInstanceGeometry vs GetSymbolGeometry

GetInstanceGeometry vs GetSymbolGeometry

pavelkosykh88
Contributor Contributor
2,353 Views
5 Replies
Message 1 of 6

GetInstanceGeometry vs GetSymbolGeometry

pavelkosykh88
Contributor
Contributor

Hi, there!

I've got a question about the methods GeometryInstance.GetInstanceGeometry() and GeometryInstance.GetSymbolGeometry().

In my file I've got only one imported dwg with only one line inside it. 

There is a code below that i use to test:

var reference = _selection.PickObject(ObjectType.PointOnElement);
var element = _doc.GetElement(reference);
var options = new Options();
options.ComputeReferences = true;
options.View = _doc.ActiveView;
            
var geometryElement = element.get_Geometry(options);
var geometryInstance = geometryElement
                .FirstOrDefault(x => x is GeometryInstance) as 
                 GeometryInstance;

var instanceGeometry = geometryInstance?.GetInstanceGeometry();
var instanceCurve=instanceGeometry?.FirstOrDefault(x => x is Curve) as Curve;
var instanceReference = instanceCurve?.Reference;
var instanceRepresentation = instanceReference?.ConvertToStableRepresentation(_doc);
            
var symbolGeometry = geometryInstance?.GetSymbolGeometry();
var symbolCurve=symbolGeometry?.FirstOrDefault(x => x is Curve) as Curve;
var symbolReference = symbolCurve?.Reference;
var symbolRepresentation = symbolReference?.ConvertToStableRepresentation(_doc);

 

After the execution I've received that:

 

instanceRepresentation=e558d96b-a4b0-449d-a84e-00d8c2768a5c-00000a38:2:1:LINEAR 
symbolRepresentation=e558d96b-a4b0-449d-a84e-00d8c2768a5c-00000c0f:0:INSTANCE:e558d96b-a4b0-449d-a84e-00d8c2768a5c-00000a38:2:1:LINEAR

where e558d96b-a4b0-449d-a84e-00d8c2768a5c-00000a38 - is uniqueId for CADLinkType

and e558d96b-a4b0-449d-a84e-00d8c2768a5c-00000c0f - is uniqueId for ImportInstance.

 

For me, it seems like these two results were mixed up. Looks like "instanceRepresentation" refers to symbol geometry, while "symbolRepresentation" refers to instance geometry.

 

I will be grateful for any help.

 

 

0 Likes
Accepted solutions (1)
2,354 Views
5 Replies
Replies (5)
Message 2 of 6

jeremy_tammik
Alumni
Alumni

I could ask the development team for you, but I know from prior experience that they would ask 'what are you trying to achieve' before even thinking about answering. So, what are you trying to achieve?

  

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

RPTHOMAS108
Mentor
Mentor

Seems logical in a way no? When you use symbol it give the full lineage of symbol and instance of that symbol. When you use the copy (with method noted below) it just gives the symbol it was copied from. There is no actual instance for it because that function just creates a copy at the time for you (is a helper method for specific purposes).

 

Beyond CADLinks you'll find that there are multiple versions of symbol geometries for a type i.e. there is often a symbol to represent each structural framing length (with such lengths being driven by instance variations not type variations). So equating symbol geometry to family symbols probably is confusing to start with. That is to say they all have different ids and at time of extraction the form of symbol geometry you get is going to be partly decided by the instance variations not just the type variations.

 

Extract RevitAPI.chm: GeometryInstance.GetInstanceGeometry

 

"...This method returns a copy of the Revit geometry. It is suitable for use in a tool which extracts geometry to another format or carries out a geometric analysis; however, because it returns a copy the references found in the geometry objects contained in this element are not suitable for creating new Revit elements referencing the original element (for example, dimensioning). Only the geometry returned by GetSymbolGeometry() with no transform can be used for that purpose."

Message 4 of 6

RPTHOMAS108
Mentor
Mentor
Accepted solution

Here is a simple example demonstrated:

Two beams of same family typeTwo beams of same family type

The short beam as id 427840The short beam as id 427840

The long beam as id 427855The long beam as id 427855

The FamilySymbol id 95037The FamilySymbol id 95037

If you check the bounding boxes extents for the two geometry symbols you'll see they match the beam lengths.

 

This gets further complicated with cuts but it demonstrates that Revit is storing geometrical symbol variations differently to how we think of the type instance relationships based on type and instance parameters.

0 Likes
Message 5 of 6

pavelkosykh88
Contributor
Contributor

I'm grateful to you!

Your explanations help a lot. It became much clearer now

0 Likes
Message 6 of 6

jeremy_tammik
Alumni
Alumni

Thank you very much for yet another very nice and helpful explanation! Preserved for posterity and future reference:

 

https://thebuildingcoder.typepad.com/blog/2021/12/symbol-instance-material-data-journal-break.html#2

  

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