Getting the scale of an importedInstance

Hi, there
I’m working on a project where I need to find the scale of an imported Instance of a .dwg file

I have tried to get the boundingBox of the imported instance, and the boundingBox of the geometry, so I can then divide each other to get the scale.
The problem is that I’m not able to get the geometry of the imported instance

here is the code:

import Autodesk.Revit.DB as DB
from Autodesk.Revit.DB import Options

dwg= IN[0]

bbox = dwg.BoundingBox

# Get the dimensions of the imported dwg file 
dx = bbox.MaxPoint.X - bbox.MinPoint.X
dy = bbox.MaxPoint.Y - bbox.MinPoint.Y
dz = bbox.MaxPoint.Z - bbox.MinPoint.Z


// this throughs error: no method matches given arguments by ByGeometry<class revit.elements.importedInstace>
geometry = dwg.Geometry(Options())

print(dir(geometry))
bbox_project = geometry.GetBoundingBox()
originalDelta = bbox_project.Max - bbox_project.Min



scale_x = originalDelta.X / dx
scale_y = originalDelta.Y / dy
scale_z = originalDelta.Z / dz

OUT = [scale_x,scale_y,scale_z]

this is so strange because the method “dwg.Geometry(Options())” is in the documentation

Can someone tell me what I’m doing wrong?

thanks

Maybe someone else can elaborate on the coding issue.

But I do question your overall method. Assuming you are importing a 2D instance of a cad drawing. I have only done some limited testing and could be mistaken. So hopefully someone will correct me if I am wrong. When getting the geometry of a 2D cad drawing, it usually returns the individual items that make up the drawing like lines, curves, polycurves, circles, etc. In that case, you would ultimately end up with a bunch of bounding boxes. If you were to consolidate all items into one geometry and get the bbox of that, I believe you would end up getting the exact same bbox that you are getting from the dwg itself with the line bbox = dwg.BoundingBox.

There is Geometry - an indexable property. Geometry
And there is a function - get Geometry.
Note the [ ] and the ( )
``
selected = uidoc.Selection.GetElementIds()
selected = [doc.GetElement(e) for e in selected]
elem = selected[0]
geo = elem.Geometry[Options()]
print(geo)
getgeo = elem.get_Geometry(Options())
print(getgeo)

Thanks for the awnser

I have tried but it gives me an error, probably because im getting a geometry from a importInstance

You can see below

Do you know a solution for this problem?