Dear All,
How to get the nearest Grid point details(XY-Co-ordinate) of a given point?
Hi,
I think you have to calculate it yourself. I checked documentation briefly and it looks to me that mdlModelRef_getGridParams is the way to go. Some grid methods exist also in VBA API, but I have not found e.g. information about grid rotation, which is mandatory to calculate grid coordinates. On the contrary, MDL function gives you all parameters at once.
Regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
I am really not that understand what you are speaking. Are you going to write this grid program?
Hai Anthony,
Actually I am having some line elements in a dgn file. I want to make that lines(vertices) to be lie on the nearest grid point(grid points are already exists in microstation dgn file by default ).
Hi Dharmarajan,
you should explain this request including some example (screen capture or design file) from very early beginning, because a small confusion in terms exists:
Without example of your file, it's hard to advice what approach is the best.
Hai Jan,
Sample.dgn file is attached for your reference. In that DGN File, the Red colored line element represents the input and the Green colored line element represents the output expected.
Unknown said: I want to make that lines(vertices) to be lie on the nearest grid point(grid points are already exists in microstation dgn file by default).
I want to make that lines(vertices) to be lie on the nearest grid point(grid points are already exists in microstation dgn file by default).
I think you can ignore the grid because vertex's coordinates are able to be extracted in VBA. Could it be done by using Math.Round (point3d.x) & Math.Round (point3d.y)?
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:
Maybe somebody else will propose simplier solution...
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...
[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 ? :-(