Grid Element Curve misbehavior?

Anonymous

Grid Element Curve misbehavior?

Anonymous
Not applicable

Hi All, 

 

I'm dealing with some issues with the curves geometry from the grid elements. In my code I asked to get te StartPoint and End Point for every grid to do some stuff later with the curve orientation.

 

I draw the grids like in the orientation as the following image:

 

image.png

The result I got is as follows:

 

image.png

 

As you can see in the schedule, the Start Point coordinates indicate that the curves were created in the opposite direction. Just to show in more detail the issue, I replicated the example in DYnamo and got the same conclusion:

 

image.png

 

So, I would like to know:

 

1.- What am I missing here?

2.- If I replicate this procedure with a wall element (for ex.) using the location of the wall, I get the coordinates according to the drawn orientation. So, Are grids working in a different way?

 

Thanks in advance for your help!

 

Cheers!

 

0 Likes
Reply
856 Views
8 Replies
Replies (8)

jeremytammik
Autodesk
Autodesk

Hi.

 

I would suggest you add functionality to your code to make it independent of the line start and end point orientation.

 

I do not believe that Revit will guarantee any specific direction.

 

Why do you need them oriented in a specific direction?

 

Cheers,

 

Jeremy



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

0 Likes

Anonymous
Not applicable

Hi Jeremy, 

 

Thanks for your response. 

 

I'm actually trying to achieve more functionality. I need to control the correct orientation because I'm creating sections automatically. I need them to be according to the plan visualization standards.

 

Hope the next images can help to understand what I'm trying to achieve:

 

Grids positioned  parallel to X and Y axis.Grids positioned parallel to X and Y axis.Grids positioned in a diagonal location.Grids positioned in a diagonal location.

If I don't have control of the orientation, the section that I'm building is created in the opposite direction and you see the element's flipped in it.

 

Thanks in advance.

 

Cheers!

0 Likes

jeremytammik
Autodesk
Autodesk

Can\t you create the section in the opposite opposite direction in the cases when that is what you need?

 

Cheers,

 

Jeremy



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

0 Likes

Anonymous
Not applicable

Hi Jeremy, 

 

Exactly, but I just to know the orientation first to pick those cases. I'm actually doing what you mentioned and it works just fine. The question I was looking here was why a grid element created from Left to Right has the Curve start point at the right and the end at the left.

 

Is it just happening with grid elements?

 

Thanks in advance.

 

Cheers!

0 Likes

jeremytammik
Autodesk
Autodesk

One thing you can probably do is:

 

  • Determine whether the curve orientation is the way you require.
  • If not, read the existing curve, invert its direction, and use Grid.SetCurveInView to flip it:

 

http://www.revitapidocs.com/2018.1/eaff0038-34f2-03cf-185b-2872cffb84af.htm

 

Cheers,

 

Jeremy



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

Anonymous
Not applicable

Thanks, Jeremy.

 

I already did something pointing in that direction. I'll dig into the method you mentioned.

 

This is my method:

 

private bool direccionCurva(XYZ sp, XYZ ep)
        {
            //Caso que las curvas sean paralelas al eje Y
            if(Math.Round(sp.X, 2) == Math.Round(ep.X, 2))
            {
                if (Math.Round(sp.Y, 2) > Math.Round(ep.Y, 2)) {
                    return false;
                }
                else
                {
                    return true;
                }
            }

            //Caso que las curvas sean paralelas al eje X
            else if (Math.Round(sp.Y, 2) == Math.Round(ep.Y, 2))
            {
                if (Math.Round(sp.X, 2) > Math.Round(ep.X, 2))
                {
                    return false;
                }
                else
                {
                    return true;
                }
            }

            //Caso que las curvas sean paralelas al eje X
            else if (Math.Round(sp.X, 2) < Math.Round(ep.X, 2) && Math.Round(sp.Y, 2) != Math.Round(ep.Y, 2))
            {
                return true;
            }
            else
            {
                return false;
            }

        }

 

Cheers!

0 Likes

jeremytammik
Autodesk
Autodesk

You can simplify your approach using a comparison operator, which might look like this:

 

    public static int Compare(
      double a,
      double b,
      double tolerance = _eps )
    {
      return IsEqual( a, b, tolerance ) 
        ? 0 
        : ( a < b ? -1 : 1 );
    }

    public static int Compare( 
      XYZ p, 
      XYZ q )
    {
      int d = Compare( p.X, q.X );

      if( 0 == d )
      {
        d = Compare( p.Y, q.Y );

        if( 0 == d )
        {
          d = Compare( p.Z, q.Z );
        }
      }
      return d;
    }

This is part of The Building Coder samples:

 

https://github.com/jeremytammik/the_building_coder_samples

 

https://github.com/jeremytammik/the_building_coder_samples/blob/master/BuildingCoder/BuildingCoder/U...

 

Cheers,

 

Jeremy



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

Anonymous
Not applicable

Thanks for the recommendation Jeremy. I'll include it in my code.

 

Cheers!

0 Likes