简体   繁体   中英

Revit Get Point(X,Y,Z) from Cad

I'm trying to get some (XY) coordinates points and rotation from an imported CAD inside Revit , but it only works right if the CAD file was never moved/rotated , this means that the Revit API get the internal coordinates of the CAD regardless of the CAD position in Revit.

now when i try the same exercise but with "Dynamo" the coordinates are right even if the CAD was moved/ Rotated

So how to make this right?

        GeometryElement geoElement = cad.get_Geometry(new Options());

        foreach (GeometryObject geoObject in geoElement)
        {
            GeometryInstance instance = geoObject as GeometryInstance;
            if (null != instance)
            {
                foreach (GeometryObject instObj in instance.SymbolGeometry)
                {
                    if (instObj is GeometryInstance) 
                    {
                        GeometryInstance gi_block = instObj as GeometryInstance;
                        Transform transform = gi_block.Transform;

                        XYZ origin =  transform.Origin; // coordinates
                        TaskDialog.Show("xx", origin.ToString());

                        XYZ vectorTran = transform.OfVector(transform.BasisX.Normalize());
                        double rot = transform.BasisX.AngleOnPlaneTo(vectorTran, transform.BasisZ.Normalize()); // angle in radians

                    }
                }
            }
        }

Maybe Dynamo is automatically adjusting for the Revit project location, rotation to north, and other global coordinate transformation settings.

The discussion of Real-World Concrete Corner Coordinates includes a description of Transforming Revit Model Coordinates to the Real World that you might be able to apply.

Check out the resulting Structural Concrete Setout Point Add-in , now alive on GitHub in the SetoutPoints repository .

You should probably first of all explore the ProjectLocation associated with your import instance. You can use RevitLookup to do so.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM