Dimension on Hatch Pattern Slab

Dimension on Hatch Pattern Slab

Anonymous
Not applicable
11,810 Views
34 Replies
Message 1 of 35

Dimension on Hatch Pattern Slab

Anonymous
Not applicable

 

Hi everyone,

I want to get dimension on hatch pattern slab like this. But I don't know how to retrieve hatch line.

Please help, thanks :).

05-May-17 10-52-26 AM.png

 

0 Likes
Accepted solutions (2)
11,811 Views
34 Replies
Replies (34)
Message 2 of 35

jeremytammik
Autodesk
Autodesk

First: Use RevitLookup to find out what elements you are after:

 

https://github.com/jeremytammik/RevitLookup

 

Second: Retrieve their geometry, asking for ComputeReferences = true.

 

Third: Create the dimensioning using the references:

 

http://thebuildingcoder.typepad.com/blog/2011/02/dimension-walls-by-iterating-faces.html

http://thebuildingcoder.typepad.com/blog/2011/02/dimension-walls-using-findreferencesbydirection.htm...

 

Cheers,

 

Jeremy



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

0 Likes
Message 3 of 35

Anonymous
Not applicable

Sorry Jeremy, I can't understand what you say.

 

First: Use RevitLookup to find out what elements you are after:

= > I already know it 's a floor and can get it.

 

Second: Retrieve their geometry, asking for ComputeReferences = true.

=> I already retrieve the solid of floor.

But the problem is from the solid I can't get geometry of line pattern in floor. (to create dimension between them).

 

Can you explain more details, please?

 

Message 4 of 35

Anonymous
Not applicable

Here my code on this project, help me 😞

 

            // Pick floor element
            IList<Element> elems = sel.PickElementsByRectangle();
            Floor fl = null;

            // Loop elems to get Floor
            foreach (Element e in elems)
            {
                if (e is Floor)
                {
                    fl = (Floor)e;
                    break;
                }
            }

            Solid s = null;
            Options o = new Options();
            o.ComputeReferences = true;
            GeometryElement geoElem = fl.get_Geometry(o);

            // Loop the geometry of Floor to get solid
            foreach (GeometryObject geoObj in geoElem)
            {
                if (s != null)
                    break;
                s = (Solid)geoObj;
            }

      // Stop here,have solid of floor but don't know how to retrieve line in fill pattern of floor :(
0 Likes
Message 5 of 35

Revitalizer
Advisor
Advisor
Accepted solution

Hi,

 

the answer is: you cannot get the geometry objects of the hatch pattern, at all.

 

You even cannot calculate the hatch line positions manually since there is no information about origin and direction in relation to the face.

Also, the  user can have edited the hatch pattern's origin by hand.

Additionally, there are two kinds of fill patterns: "model" and "drawing". One of them depends on view's scale, the other not.

You can analyze the related FillPattern's FillGrids, but you don't have the logical connection to the Face's coordinates.

 

So, no, it cannot be done.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 6 of 35

FAIR59
Advisor
Advisor
Accepted solution

@Revitalizer: you are right that there is no direct way to get to hatch lines. However we have just about enough information to construct them.

 

I had a hunch, that the reference to the surface and to the hatch lines are related. For the Reference.ConvertToStableRepresentation() you get:

Surface:       926c1621-1982-4ef6-bcbc-21fe350f0087-001f2d0b:1:SURFACE

Hatch Line:  926c1621-1982-4ef6-bcbc-21fe350f0087-001f2d0b:1:SURFACE/6

 

So given a StableRepresentation of a surface , you can construct a Reference to a hatch line with

Reference HatchRef = Reference.ParseFromStableRepresentation(doc, StableRepresentation of Surface + "/index"), where index is an integer >1

 

The indices are distributed over the different Hatch Lines as follows:

 

HatchLine_Index.PNG

Take 2 references to a HatchLine and you can create a dimension. Once you have the dimension, you can determine the direction and position of the "unbound"lines.

 

Here is my code the create that dimension:

                Floor _floor;
               Reference top =  HostObjectUtils.GetTopFaces(_floor).First();
               PlanarFace topFace =   _floor.GetGeometryObjectFromReference(top) as PlanarFace;
//check for model surfacepattern
               Material mat = doc.GetElement(topFace.MaterialElementId) as Material;
               FillPatternElement patterntype = doc.GetElement(mat.SurfacePatternId) as FillPatternElement;
               if (patterntype== null)    return   Result.Failed;
               FillPattern pattern =  patterntype.GetFillPattern();
               if (pattern.IsSolidFill || pattern.Target == FillPatternTarget.Drafting) return Result.Failed;

// get number of gridLines in pattern                
               int _gridCount = pattern.GridCount;

// construct StableRepresentations and find the Reference to HatchLines
               string StableRef = top.ConvertToStableRepresentation(doc);
               ReferenceArray _resArr = new ReferenceArray();
               for (int ip = 0; ip < 2; ip++)
               {
                   int index = 1 + (ip * _gridCount *2); 
                   string StableHatchString = StableRef + string.Format("/{0}", index);
                   Reference HatchRef = null;
                   try
                   {
                       HatchRef = Reference.ParseFromStableRepresentation(doc, StableHatchString);
                   }
                   catch
                   { }
                   if (HatchRef == null) continue;
                   _resArr.Append(HatchRef);
               }
// 2 or more References => create dimension
                if (_resArr.Size>1)
                {
                    using (Transaction t = new Transaction(doc,"dimension Hatch"))
                    {
                        t.Start();
                        Dimension _dimension = doc.Create.NewDimension(doc.ActiveView, Line.CreateBound(XYZ.Zero, new XYZ(10, 0, 0)), _resArr);
// move dimension a tiny amount to orient the dimension perpendicular to the hatchlines
// I can't say why it works, but it does.
                        ElementTransformUtils.MoveElement(doc, _dimension.Id, new XYZ(.1, 0, 0));
                        t.Commit();
                    }
                }

   

 

Message 7 of 35

Anonymous
Not applicable

Dear FAIR59.

 

I got through this problem by using a FilledRegion previous set on the floor pattern (FilledRegion dimension should be equal to one tile dimension).

So I can locate one tile on Floor, then create a dimension from that to others.  So the first version pretty works.

 

I will try your version later ( need time to comprehend this :D).

 

Anyway, thank you very much.

0 Likes
Message 8 of 35

Revitalizer
Advisor
Advisor

Hi,

 

if it would be possible, I would give you a double kudo for that creative approach.

 

Another gem in the "undocumented relationships" collection.

 

@Anonymous: Seems that you should unmark my answer and mark FAIR59's instead, as solution.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 9 of 35

jeremytammik
Autodesk
Autodesk

Totally agree this is a totally cool solution, and published it for future reference:

 

http://thebuildingcoder.typepad.com/blog/2017/06/hatch-line-dimensioning-voodoo.html#4

 

Thank you very much, Fair59!

 

Cheers,

 

Jeremy



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

0 Likes
Message 10 of 35

Anonymous
Not applicable

Hi,

 

I have a similar slab that I have hatched. I now want to display only the dimensions of the sides (length and breadth) through a small C# script. Could you please help me out?

0 Likes
Message 11 of 35

FAIR59
Advisor
Advisor

I have posted some code as an answer to another question , that should give you enough pointers to implement your code.

https://forums.autodesk.com/t5/revit-api-forum/use-of-align-function-programatically-to-change-the-a...

0 Likes
Message 12 of 35

Anonymous
Not applicable

FAIR59, thanks so much for your solution - we've been able to use this to make a script that can interpret a ceiling tile grid based on two dimensions using your technique. Unfortunately, we've come across the problem that, using your technique, if a user has manually moved or rotated the ceiling grid prior to the script being applied, the dimensions created from the references apply to the original positions of the reference ceiling lines.

 

Have you come across this yourself? Any idea what we might do to address it?

 

asdfghj.JPG

0 Likes
Message 13 of 35

FAIR59
Advisor
Advisor

the top and bottom of a ceiling (1 material) have their own independent hatches. You apply the dimensions to the wrong surface. 

Message 14 of 35

Anonymous
Not applicable

Oops! Well that makes perfect sense - forgot to change the reference moving from a floor to a ceiling. Thanks for the quick response!

0 Likes
Message 15 of 35

mahmoudabdelmoneam
Explorer
Explorer

@FAIR59, I'd like to thank you for the innovative approach, infinity likes.

This works in a very cool way with dimensions, I also had a thought, I think we can use this approach to align the model pattern, by moving the floor itself, then adjusting its sketch. All by knowing the dimension position from the Dimension.Segments.

 

 

 

 

0 Likes
Message 16 of 35

BardiaJahan
Advocate
Advocate

Now any idea about how to get the actual geometry of the gridline from Reference? Let's say to create a model line that overlaps the gridline?

Message 17 of 35

mahmoudabdelmoneam
Explorer
Explorer

I guess you can use @FAIR59 workaround, he draws a dimension to know where are the pattern grids, their angle, and the distance between them. Once you know that, you can use this to draw several lines (maybe unbound) then you can intersect them with the floor face edges ignoring lines outside of the floor.

0 Likes
Message 18 of 35

BardiaJahan
Advocate
Advocate

yes @FAIR59 's workaround gives References to the grid lines and we can use it to create a dimension string. But I'm trying to figure out how to get XYZ coordinates of the grid line or only one point on it so that I can draw a line that overlaps the gridline.

Message 19 of 35

mahmoudabdelmoneam
Explorer
Explorer

Given a dimension from @FAIR59 method, you can get a the dimension line and the dimension segments, using the dimension line direction, a segment origin, and a segment value, you can get two parallel lines for the model pattern in XYZ coordinates. Intersect these with the floor face edges, and you have 2 grids, repeat it several times, you should have all the model pattern lines.

Have a look at the helper method posted by @FAIR59 in this post:

 

https://forums.autodesk.com/t5/revit-api-forum/use-of-align-function-programatically-to-change-the-a...

 

 

Message 20 of 35

BardiaJahan
Advocate
Advocate

@mahmoudabdelmoneam  You're right, I can get the segment origin, totally forgot, today is a Friday after all!! Thanks.