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: 

Z coordinate is ignored while inserting face-hosted nested family instance

2 REPLIES 2
Reply
Message 1 of 3
tobiazambon
410 Views, 2 Replies

Z coordinate is ignored while inserting face-hosted nested family instance

Hello, I'm trying to insert a face-hosted family that contains a void extrusion inside a generic specialty equipment family. The scenario is the following:

 

- In the "parent" family there is a rectangular extrusion placed with Z = 100 mm and height = 40mm; the extrusion is created programmatically

- I've a rfa with a simple void cylinder. This rfa is a Generic model family and I've set "Cut with voids" to true

- I want to insert an instance of this void family inside the parent family in order to pierce the extrusion.

The code I'm using is the following:

 

            Options opt = _commandData.Application.Application.Create.NewGeometryOptions();
            opt.ComputeReferences = true;
            var geo = shelf.get_Geometry(opt);//shelf is the extrusion
//location = 0,-800,100
//width = 1000
//depth = 800
//height = 140
//all measures are mm
            PlanarFace pf = null;
            foreach (GeometryObject obj in geo)
            {
                Solid solid = obj as Solid;

                if (null != solid)
                {
                    foreach (Face face in solid.Faces)
                    {
                        pf = face as PlanarFace;
                        if (null != pf)
                        {
                            XYZ normal = pf.Normal.Normalize();
                            if (0.0 < normal.Z && normal.X < 1 && normal.Y < 1)
                            {
                                break;
                            }
                        }
                    }
                }
            }
            if (pf != null)
            {
                var location = new XYZ(50D.ToRevitMeasure(), -100D.ToRevitMeasure(), 140D.ToRevitMeasure());
                var referenceDirection = XYZ.BasisX;
                FamilySymbol symbol = null;
                RevitBaseUtilities.DoSomethingInsideTransaction(() => familyDocument.LoadFamilySymbol(holeFileName, Path.GetFileNameWithoutExtension(holeFileName),
                                                                                                      new FamilyLoadingDontOverwriteOption(), out symbol), familyDocument);


                FamilyInstance inst;
                RevitBaseUtilities.DoSomethingInsideTransaction(() => inst = familyDocument.FamilyCreate.NewFamilyInstance(pf, location, referenceDirection , symbol), familyDocument);
               
                familyDocument.SaveAs(resultFileName);
                familyDocument.Close(false);

 

 

 

The problem is that the cylinder is always placed in Z=0, attached you can find the hole family and the result I get.

Thank you!

 

2 REPLIES 2
Message 2 of 3
Joe.Ye
in reply to: tobiazambon

 

Hello,

 

As the host face's Z coordinates is 0, the void family instance is based on the host face.  I think that's why the Z coordinates is ignored.



Joe Ye
Contractor
Developer Technical Services
Autodesk Developer Network
Message 3 of 3
tobiazambon
in reply to: Joe.Ye

Mmm..I think that the Z of the host face is not 0 but 140 mm..

Did you see the 0 in the attached file result.rfa (in the original post)? Where should I look for?

 

Thank you

Tobia

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community