Understanding Transforming points


I’m struggling to understand how points are transformed between elevation views and the world coordinate system.

I’m using this to amend the CropBox of an elevation view, the XYZ points of the lower left and upper right of the crop box are returned in the views local coordinate system, I then need to convert to the world coordinate system.

This part is easy:

This code looks for an elevation called ‘TEST’ and then obtains its CropBox XYZs:

allViews = FilteredElementCollector(doc).OfClass(View).ToElements()

viewtopick = "TEST"

for f in allViews:
    if f.Name == "TEST":
	    viewtouse = f

#Get View cropbox
viewcropbox = viewtouse.CropBox

#Set View cropbox minimum value

mincb = viewcropbox.Min
maxcb = viewcropbox.Max

minpos = viewcropbox.Transform.OfPoint(mincb)
maxpos = viewcropbox.Transform.OfPoint(maxcb)

The Cropbox.Transform.OfPoint() method converts the local coords to the world coords - nice and easy.

But in order to amend the view I need to calculate some points going the other way around - i.e. from World coordinate system to view local coordinates.

I can’t find a method of using .Transform backwards.


Have you tried using the inverse of the original transform?



Wow - its really that easy?

That works perfectly, thanks.

I didn’t realise that the Transform property of the BoundingBoxXYZ class is actually the Transform class (where .inverse lives).

How would you know this? The API help file does not seem to link the two in any way - unless I’m missing something.

Thanks for your help.