planarFace in ReferenceLine

planarFace in ReferenceLine

MarryTookMyCoffe
Collaborator Collaborator
620 Views
3 Replies
Message 1 of 4

planarFace in ReferenceLine

MarryTookMyCoffe
Collaborator
Collaborator

Hi,
I try to create a ConnectorElement on ReferenceLine(like in Connector.png) but I still have null as reference, here is part of my test code:

        private void again(ref ModelCurve mcurve, View view)
        {
            using (SubTransaction subT = new SubTransaction(_Family))
            {
                subT.Start();

                _Family.Regenerate();
                Options opt = new Options();
                opt.ComputeReferences = true;
                opt.IncludeNonVisibleObjects = true;
                opt.View = view;
                opt.ComputeReferences = true;

                GeometryElement ge = mcurve.get_Geometry(opt);
                foreach (Solid solid in ge)
                {
                    foreach (PlanarFace item in solid.Faces)
                    {
                        if (item.FaceNormal.IsAlmostEqualTo(XYZ.BasisX) || item.FaceNormal.IsAlmostEqualTo(-XYZ.BasisX))
                        {
                            //why is null
                            ConnectorElement.CreatePipeConnector(_Family, PipeSystemType.Global, item.Reference);
                        }
                    }
                }
                subT.Commit();
            }   
        }

but PlanarFace reference is still null, how can I get Reference for PlanarFace?

I look at:
https://forums.autodesk.com/t5/revit-api-forum/how-to-get-the-reference-of-a-planarface/td-p/6489839

http://www.revitapidocs.com/2016/6fdcd1e4-61d0-2a01-2e5b-b5d918f0cfee.htm

for some reason all this method don't what to work with ReferenceLine.

I made a referenceLine with

                SketchPlane sketchPlane = SketchPlane.Create(_Family, view.GenLevel.Id);
                Curve curve = Line.CreateBound(new XYZ(-2, 0, 0), new XYZ(2, 0, 0));
                using (SubTransaction subT = new SubTransaction(_Family))
                {
                    subT.Start();
                    mLine = _Family.FamilyCreate.NewModelCurve(curve, sketchPlane);
                    mLine.ChangeToReferenceLine();
                    subT.Commit();
                }
                    _Family.Regenerate();

I work on Revit 2017

-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug
0 Likes
621 Views
3 Replies
Replies (3)
Message 2 of 4

FAIR59
Advisor
Advisor

As you say, the references for a Reference Line are null. I suggested  a possible work-around in this discussion https://forums.autodesk.com/t5/revit-api-forum/reference-plane-from-reference-point/m-p/7308290

0 Likes
Message 3 of 4

MarryTookMyCoffe
Collaborator
Collaborator

thx for replay,
This is like the first thing I try, but I get Error 

FamilyContextException

" Element cannot be created in current context"

 I thing you can only use it in MassTemplate and I work on GenericModel

-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug
0 Likes
Message 4 of 4

MarryTookMyCoffe
Collaborator
Collaborator

for me it's bug, we should be able to get that reference from referecneLine

-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug
0 Likes