Author Topic: Getting a distance between two points from a C# array of points  (Read 2067 times)

0 Members and 1 Guest are viewing this topic.

sonny3g

  • Newt
  • Posts: 27
What I have to do is first determine a point at floor level.  Then a point at the top level followed by up to 7 more points located somewhere between the floor level and the top level.  I am able to create the collection of points okay, but I need to get two height variables for each point except the floor level point.

 So, I need to know the distance from the floor level point and the top level point, then from the floor level to the next selected point (the selected points may be  in random order - floor level, top level, level 3, level 4, level 2, level 1).  This makes up the first set of distances I need.

The second set of distances I need is the spread between each point.  So, in a 6 level drawing I need to know how far is the 1st level point from the floor point, then how far is the 2nd level point from the 1st level point and so on up the to top level. 

I can have anywhere from 2 levels to 8 levels to work with.  Also, all points are in a vertical line so their X value should all be the same. 

The final problem and why I have to figure out how to get DistanceTo to work is that orientation of the view will be below the X plane of the drawing so Y will be going from the largest negative number at floor level up the lowest negative number for the top level.  Or it could be a rotated view and UCS.

So far, I cannot get DistanceTo to work in C# nor can I get GetDistance to work.

Any suggestion will be greatly appreciated!

WILL HATCH

  • Bull Frog
  • Posts: 450
Re: Getting a distance between two points from a C# array of points
« Reply #1 on: April 25, 2018, 04:35:52 PM »
I was going to answer, but I see gile is looking at this already and will have a better answer  :whistling:

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Getting a distance between two points from a C# array of points
« Reply #2 on: April 25, 2018, 04:35:58 PM »
Hi,

If the Height is measured parallel to Y axis (2D), just substract the Y coordinate of the floor level point from the Y coordinate of the point you want the height.
If you work in 3D, it's the samething with Z coordinates of the points.

@WILL HATCH, I'm not sure I correctly understand the question...
Speaking English as a French Frog

sonny3g

  • Newt
  • Posts: 27
Re: Getting a distance between two points from a C# array of points
« Reply #3 on: April 26, 2018, 08:53:20 AM »
Thanks for taking a look at my post and responding.

I did that first and was getting unreliable results.  Then I thought about how would it work if my block in the attached image was being inserted at an angle or an odd ucs? 

To get a little more into what I am trying to accomplish.  The attached image shows a support that is a dynamic block.  The users will pick the alignment point for the X parameter.  Then they will pick a the floor line to establish the Y basepoint and the top level support point for the max Y point.  The user will then be asked to pick a point on the remaining conveyors to establish each required support Y point.

There are a minimum number of crossmembers required dependant on the overall height of the support and no two supports can be more than 54" apart while the bottom support has a min/max from floor it can be moved.

Once I have all of the support points determined, I will cycle through to determine the spread between each crossmember for the max dim of 54".  There is a lot more calculations I need to make to determine exact placement of each crossmember based on other parameters like type of mounting required to attach to the conveyor.  That is another story.

Finally, once all the Y points are determined I insert my dynamic block and cycle through the crossmember height properties assigning the correct floor to Y point value to each.

So far, just trying to subtract one Y value from the previous is not giving me back reliable results.  Therefore I was hoping that using DistanceTo or GetDistance would provide more reliable results.


sonny3g

  • Newt
  • Posts: 27
Re: Getting a distance between two points from a C# array of points
« Reply #4 on: April 26, 2018, 09:26:16 AM »
I figured out what I did wrong.  I needed to assign the value of each of my prompointresults to a point3d variable and then use it to get DistanceTo between my points.

Thanks for the help guys.