Create dimension based on the column center

Anonymous

Create dimension based on the column center

Anonymous
Not applicable

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!

0 Likes
Reply
Accepted solutions (1)
2,001 Views
2 Replies
Replies (2)

jeremytammik
Autodesk
Autodesk
Accepted solution

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

Anonymous
Not applicable

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!

0 Likes