New Dimension are not Visible

New Dimension are not Visible

Anonymous
Not applicable
1,663 Views
5 Replies
Message 1 of 6

New Dimension are not Visible

Anonymous
Not applicable

Hi Everybody,

 

I'm actually trying to create a new dimension for a Rebar element.

To sum up I try to do something like the MultiAnnotation Command but without the Tag.

After further research, I found a way to catch the reference of each Rebar of the Rebar Distribution and to put a dimension on it, but the Problem is the following :

The function Create.Newdimension (on the last line of my code) returns me a dimension but at the end of the execution, I can't see this dimension. 

 

                        Options opt = app.Create.NewGeometryOptions();
                        opt.ComputeReferences = true;
                        opt.IncludeNonVisibleObjects = false;
                        opt.View = doc.ActiveView;

                        ReferenceArray referenceArray = new ReferenceArray();
                        List<XYZ> ListPoint = new List<XYZ>();

                        GeometryElement geometryElement = rebar.get_Geometry(opt);

                        foreach (GeometryObject obj in geometryElement)
                        {
                            if (obj is Solid)
                            {
                                Solid solid = obj as Solid;
                                FaceArray faceArray = solid.Faces;

                                // Search the biggest Face Area
                                Face BiggestFace = faceArray.get_Item(0);
                                foreach (Face face in faceArray)
                                {
                                    if (face.Area > BiggestFace.Area)
                                    {
                                        BiggestFace = face;
                                    }
                                }

                                Face fa = BiggestFace;
                                {
                                    if (fa != null)
                                    {
                                        PlanarFace planarFace = fa as PlanarFace;
                                        XYZ point = planarFace.Origin;
                                        Reference refer = planarFace.Reference;

                                        if (refer != null && referenceArray.Size < 3) //I only need the 2 first Rebar Faces of the Rebar distribution
                                        {
                                            referenceArray.Append(refer);
                                            ListPoint.Add(point);
                                        }
                                    }
                                }
                            }
                        }
                        using (Transaction t = new Transaction(doc, "Creation Ligne de cote"))
                        {
                            t.Start();
                            Line line1 = Line.CreateBound(ListPoint[0], ListPoint[1]);
                            Dimension newDimension = doc.Create.NewDimension(doc.ActiveView, line1, referenceArray);
                            t.Commit();
                        }

 

Does somebody have an Idea why the new Dimensions are not visible?

I already tried many modifications on the code, but I can't find if the Origin of the problem comes from the ReferenceArray or from the dimension ...

 

Thanks in Advance,

0 Likes
1,664 Views
5 Replies
Replies (5)
Message 2 of 6

jeremytammik
Autodesk
Autodesk

Please refer to this other discussion on fixing a non-visible dimension after copying it from another view:

 

https://forums.autodesk.com/t5/revit-api-forum/copy-dimensions-from-a-view-to-another/m-p/7226217

 

Maybe that solution will help in your case as well?

 

I already suggested this in a previous thread:

 

https://forums.autodesk.com/t5/revit-api-forum/newdimension-dimension-created-but-not-visible/m-p/63...

 

Please always search the forum for existing answers before posting a new question.

 

Please also let us know how you end up solving your issue.

 

Thank you!

  

Cheers,

 

Jeremy

 



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

0 Likes
Message 3 of 6

Anonymous
Not applicable

Thanks Jeremy for the other threads.

I read them but I couldn't solve the problem with these different solutions.

 

During the week I continue to check my code and I found an interesting point which is probably at the origin of the problem.

To obtain the reference of "theBiggestFace" I execute the following code :

Face theBiggestFace;
PlanarFace planarFace = theBiggestFace as PlanarFace;
Reference refer = planarFace.Reference;

With this code I obtain a Reference which ElementReferenceType is "REFERENCE_TYPE_SURFACE", and in my case (with the faces are parallel to the view) the Dimension will only work with "REFERENCE_TYPE_LINEAR".

Reference-surface.PNG

Do you have an idea of how to obtain a Reference with a type : "Linear" from a Reference with a type : "Surface" ?

 

It's probably a simple additional line at my existing code, but I couldn't find it by myself ...

 

Thanks,

0 Likes
Message 4 of 6

jeremytammik
Autodesk
Autodesk

Did you succeed in solving this?

 



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

0 Likes
Message 5 of 6

Anonymous
Not applicable
Yes and No. 😁
I couldn’t properly found the reference line from the face so I do it now from an other way.

I catch now all the geometrics objects from the view (visible and invisible) and then I filter all these elements to find:
- a reference line parallel to the middle axis of the face;
- the closest reference to the middle axis.

It’s a dirty solution, but it works and with a good filtering the performance stay acceptable.
0 Likes
Message 6 of 6

jeremytammik
Autodesk
Autodesk

Thank you very much for sharing your interesting approach.

 

I am glad to hear it works and is sufficiently performant.

  

I asked, because I cleaned out a bunch of dimensioning issues in my blog post yesterday:

 

http://thebuildingcoder.typepad.com/blog/2018/09/rebar-wall-centreline-core-and-grid-dimensioning.ht...

 

Maybe I should add this idea of yours as well?

 

Cheers,

 

Jeremy

 



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

0 Likes