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: 

Create dimension based on the column center

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Anonymous
1996 Views, 2 Replies

Create dimension based on the column center

Hi

 

I used below code to create a Dimension.

Reference refElement0 = sel.PickObject(ObjectType.Element, "selectColumn0");
            Reference refElement1 = sel.PickObject(ObjectType.Element, "selectColumn1");
            FamilyInstance familyInstance0 = Doc.GetElement(refElement0) as FamilyInstance;
            FamilyInstance familyInstance1 = Doc.GetElement(refElement1) as FamilyInstance;

            FaceArray faces0 = GetFaceArrayOfFamilyInstance(familyInstance0);
            FaceArray faces1 = GetFaceArrayOfFamilyInstance(familyInstance1);
            Face face0 = null;
            Face face1 = null;
            foreach (Face face in faces0)
            {
                XYZ faceNormal = GetFaceNormal(face);
                if (faceNormal.IsAlmostEqualTo(new XYZ(0, -1, 0)))
                {
                    face0 = face;
                    break;
                }
            }

            foreach (Face face in faces1)
            {
                XYZ faceNormal = GetFaceNormal(face);
                if (faceNormal.IsAlmostEqualTo(new XYZ(0, -1, 0)))
                {
                    face1 = face;
                    break;
                }
            }
            ReferenceArray refArray = new ReferenceArray();
            refArray.Append(face0.Reference);
            refArray.Append(face1.Reference);

            using (Transaction t = new Transaction(Doc, "CreateDimension"))
            {
                t.Start();
                LocationPoint locationPoint0 = familyInstance0.Location as LocationPoint;
                LocationPoint locationPoint1 = familyInstance1.Location as LocationPoint;
                Line lineDimension = Line.CreateBound(locationPoint0.Point, locationPoint1.Point);
                Doc.Create.NewDimension(Doc.ActiveView, lineDimension, refArray);
                t.Commit();
            }

As expected,the reslut is like below:

 

无标题.png

 

But.. I really want is like below ..which is to create dimension based on the column center like manually createing the dimension from revit UI (can select the center line of a column). And what does this bule line represent, Face? Plane? Line?

无标11题.png

 

Any idea on how to implement this? Thx!

2 REPLIES 2
Message 2 of 3
jeremytammik
in reply to: Anonymous

Yes, I hope so.

 

Check out this recent discussion:

 

http://thebuildingcoder.typepad.com/blog/2017/05/api-access-to-family-instance-references.html

 

I hope it helps.

 

Please let us know how it goes and how you end up resolving this.

 

Thank you!

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 3
Anonymous
in reply to: jeremytammik

Hi Jeremy,

 

Sorry for the late reply.

 

I refered to Picking Pairs and Dimensioning Family Instance Origin and get the column origin line for creating the dimension. It worked.

 

Thanks a lot!

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

Post to forums  

Autodesk Design & Make Report