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: 

Dimension on Hatch Pattern Slab

25 REPLIES 25
SOLVED
Reply
Message 1 of 26
Anonymous
7626 Views, 25 Replies

Dimension on Hatch Pattern Slab

 

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

 

25 REPLIES 25
Message 2 of 26
jeremytammik
in reply to: Anonymous

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

Message 3 of 26
Anonymous
in reply to: jeremytammik

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 26
Anonymous
in reply to: Anonymous

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 :(
Message 5 of 26
Revitalizer
in reply to: Anonymous

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 26
FAIR59
in reply to: Anonymous

@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 26
Anonymous
in reply to: FAIR59

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.

Message 8 of 26
Revitalizer
in reply to: FAIR59

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





Message 9 of 26
jeremytammik
in reply to: Anonymous

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

Message 10 of 26
Anonymous
in reply to: Anonymous

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?

Message 11 of 26
FAIR59
in reply to: Anonymous

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...

Message 12 of 26
Anonymous
in reply to: FAIR59

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

Message 13 of 26
FAIR59
in reply to: Anonymous

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 26
Anonymous
in reply to: FAIR59

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

Message 15 of 26
mahmoudabdelmoneam
in reply to: FAIR59

@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.

 

 

 

 

Message 16 of 26
BardiaJahan
in reply to: FAIR59

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 26

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.

Message 18 of 26

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 26

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 26

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

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

Post to forums  

Autodesk Customer Advisory Groups


Rail Community