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: 

Grid Element Curve misbehavior?

8 REPLIES 8
Reply
Message 1 of 9
Anonymous
780 Views, 8 Replies

Grid Element Curve misbehavior?

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!

 

8 REPLIES 8
Message 2 of 9
jeremytammik
in reply to: Anonymous

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

Message 3 of 9
Anonymous
in reply to: jeremytammik

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!

Message 4 of 9
jeremytammik
in reply to: Anonymous

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

Message 5 of 9
Anonymous
in reply to: jeremytammik

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!

Message 6 of 9
jeremytammik
in reply to: Anonymous

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

Message 7 of 9
Anonymous
in reply to: jeremytammik

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!

Message 8 of 9
jeremytammik
in reply to: Anonymous

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

Message 9 of 9
Anonymous
in reply to: jeremytammik

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

 

Cheers!

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

Post to forums  

Forma Design Contest


Rail Community