Find nearest Grid Point

Dear All,

How to get the nearest Grid point details(XY-Co-ordinate) of a given point?

Parents Reply Children
  • Hi,

    so you are talking about grid in view at the end ;-) In such case your previous information is not correct, because grid displayed in views doesn't exist in a design file, it's displayed dynamically together with the model content. What exist in the file are parameters only (in what view the grid should be displayed and how).

    Because there is no function (at least I have not found any) that returns the nearest grid point, you have to calculated it yourself. You probably should use mdlModelRef_getGridParams function as I mentioned earlier to receive information about grid. If you know the grid is fixed with model global coordinate system and not e.g. rotated with view, the situation is much easier. After you will be able to calculate grid points, it should be easy to extend it to search for the nearest one.

    So a conclusion is you have to write at least:

    • Code to "reconstruct" grid from the given parameters.
    • Code to find the nearest grid point to a defined coordinates.
    • Code to find all elements that should be processed.
    • Code to traverse through all vertices of a particular element and to move every vertex to the nearest grid point.

    Maybe somebody else will propose simplier solution...

    Regards,

      Jan

  • This reply was deleted.
  • Unknown said:
    May I know why can't you and Jon Summers just provide a simple solution instead of typing massive words?

    It's the topic for another thread, but how you imagine it would work? The original question was "How to get the nearest Grid point details(XY-Co-ordinate) of a given point?", so I provide my opinion what the steps are.

    What is "simple solution" for you? Would you like we will write a code for you? At first, it was not the original question, at second, it's pretty time consuming. Will you pay us for it?

    Unknown said:
    For example, dialog redraw bug, you said hook, event etc massive things.... why can't just provide me the solution : (

    If I remember right, I told you where the problem is and that it's already reported as a bug. The solution discussed was you have to hook and process redraw events by yourself. It should be enough for developers.

    Forums are based on voluntary participation and there is no duty to provide the final solutions, just advices and opinions. If you expect I will invest a couple of hours for free to solve all discussed problems, especially if the topic is complex like bug in dialog redraw, such expectation is far from reality.

    I invest a huge amount of my time to try to help users here (and it's also a way how to learn new things). And if possible, because I have it already in my archive, I often also provide hands-on help in a form of files, settings or even a code. I don't feel any doubts I help other users. And if it's not what you want to receive, sorry for that, that's the difference between public forums where a knowledge is shared and paid service.

    Unknown said:
    Western people love doing that?!

    It's not very nice but offensive...

    Regards,

      Jan

  • [Admin note: We are very serious about keeping this site constructive and professional in nature. Explicit or inferred expletives will be removed when found with no questions asked. Further, posts containing these things may be removed completely. Continued use of such will result in you being moderated (i.e. anything you post will need to be approved before appearing in the forums) and potentially being banned from the site.]

    You typed another massive words...... I am not asking offensively....

    Arr.... Let me try to make an example for you.

    A student asks: what is the value of PI?

    Normally we will answer: PI = 3.141592653......

    And you will answer like that: What is the PI you are meaning to? Give me more information! It is not enough!  Hey! Wrong! Firstly you need to draw a circle. Secondly ... you'd never provide the key point to that student: "3.141592"

    Got it ? :-(

  • Dear Bentley Moderators / Administrator,

    I think Jan have read my explanation.

    Please delete the above off-topic post.

    Regards,

    Anthony

  • Normally, I try to stay out of emotional exchanges, but in this particular instance, something really needs to be said.

    In situations where what is being asked is unclear, you can expect questions and possibly some level of explanation to try to identify details that the person asking the question may have a clear understanding of, but everyone else does not. This has happened and will continue to happen. This may not be normal to you, but it is quite normal in today's day and age. it is also one of a number of points that I strongly encourage everyone become familiar with -- see Be Communities forums tips for those.

    The scenario you infer -- A student asks: what is the value of PI... blah, blah, blah -- is much more discrete than what was asked. Of course, if the question is "What is the next number after 1", the answer will be 2 (hopefully, that question will never be asked, though, as a simple search would provide that information). In situations where what is being asked is not as obvious, though... as is the case here, particularly where there are different cultural and language backgrounds involved, we ask that you simply provide what you believe is helpful information (including asking questions and offering explanation to help clarify what was asked) and others will do the same.

    If you really have the urge to attack how others (especially those who are very helpful) approach providing solutions, we ask that you either keep that to yourself or connect with the person directly offline. If you have a problem with this, please contact me (offline) as any further exchange regarding this off-topic subject will be removed.

    Now, let's get back to the original thread. TIA