Hi,
I am writing an application (AddStageNumbers.mvba) to add Items to shapes found inside or on boundary shapes, my problem is determining if shape1 is inside shape2 the boundary shape.
I have attached the mvba project for clarity and understanding, along with its references and a simplified example dgn file. There is application description and instructions included in the app.
I have used Point3dInPolygonXY to determine if the vertices of the shapes are inside, on, or outside the boundary shape but it fails sometimes when arcs are included in the shapes as the vertices for the arcs are not always on the element. I have tried using the vertices of all the elements that make up the shapes and that improved it somewhat but it still sometimes finds elements with vertices outside the boundary, that have been created with the create region tool and are clearly inside or on the boundary. (refer to the red complexshape in the dgn file)
Is there another method that I can use that is more likely to be more accurate, or is there anything else I can try to get the desired result?
I am using MicroStation update 15, and it will have to run on update 13, and 14 also at this point in time.
DialogPositioning.mvbaAddStageNumbers.mvbaQ_Sort.mvbaProblem shape.dgn
Taking a quick look at your code the tolerance for you specify for the ConstructVertex method is way too large.
'Get vertices for oelem1 Points = oElem1.ConstructVertexList(1)
You have it set to 1, try setting it to .01 and see if that changes your results.
My other question is why are you iterating through each sub element of complex shapes individually, getting those verticies, and appending to an array? You can just do a ConstructVertexList on the Complex Shape element and not have to go through those gyrations.
Rod WingSenior Systems Analyst
Hi Jan,Jon,Rod,
Thanks for your valued information, the project is related to subdivision stages and I exhausted the use of fences using many different combinations also using the copy parallel options so that the fence was outside the actual boundary but it can't be done with vba as the copy parallel options cannot be guaranteed to copy to the correct side, and where the stage boundaries are adjoining it is impossible to tell if you have the correct boundary.
Other problems encountered were, the property shapes could be abutting the boundary on both inside and outside the stage boundary. Complexshapes containing arcs can have vertices quite obviously inside or outside the actual shape elements and that is the reason I have cycled through each element in both the inner and outer shapes, which made quite an improvement.
I also found the reason for the few shapes that were missed, it was due to property corner vertices on the stage boundary at part of an arc in the boundary where the bounding shape would be tested with a straight line between the points on the arc either side of the property corner point. I guess I could calculate more points along each arc to make it more accurate, but that would probably slow the processing down considerable and still not get those missing shapes.
There is probably other implications also, and what I have so far is sometimes only missing a few shapes, and I can get the user to process them manually.
So thanks once again for you valued help.
Best Regards,
John.
John Davidson said:The project is related to subdivision stages ... the property shapes could be abutting the boundary
It looks like you're trying to reinvent the GIS wheel using VBA. That's not a road I would choose to take.
GIS products, such as OpenCities Map (formerly Bentley Map) provide heaps of tools for spatial analysis, including the kind of work you want to perform. I don't know how much time you have spent on this, and other related tasks, but if it has taken more than a few weeks then your organisation has already spent the license fee for Map in salary.
Regards, Jon Summers LA Solutions
Hi John,
John Davidson said:the project is related to subdivision stages
as Jon wrote, your explanation sounds like GIS operation.
In general, there are two (quite opposite) approaches when working with data (not graphical only):
Because you are in the second situation. It does not mean it cannot be solved (or at least, an approach able to process 99% of situations, but not all), but VBA is really bad tool to try to reach such goal. It's both because of MicroStation VBA API limitations (both NET and C++ APIs provides rich topology structures, even when MicroStation is not GIS), but also because of VBA itself. Both C# and C++ allows to write more efficient code, because perfectly implemented libraries are available for any task you can imagine.
John Davidson said:but that would probably slow the processing down considerable
I do not think it's true. Even when VBA is slow and not very efficient "by definition", 99% of performance problems I saw were caused by wrong algorithm, not because VBA was used.
John Davidson said:So thanks once again for you valued help.
It's my pleasure, but I dislike the situation when good final solution is not found (and unfortunately, in the discussed case, cannot be found).
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Thanks Jon/Jan,
This app is just a small step to a much bigger picture of the processes we undertake and will be looking at Open Cities and other ways to improve our productivity. There are so many new technologies available now and we need to continually review how we do things, but this process has been ignored for too long and needed something to kick off the inspiration of our users to think outside the box.
Thanks again for your help.
John Davidson said: We will be looking at Open Cities and other ways to improve our productivity
That should solve a few problems and reduce the need for development.
John Davidson said: There are so many new technologies available now ...
Well, yes, and they've been in development for other languages (C# and C++, Python, Java) for decades. There are libraries that you can buy or borrow, but not for VBA. In other words, developers of advanced libraries for GIS, linear algebra, image processing etc. consider modern languages and ignore legacy technology from the 20th century.
For illustration, here are some libraries that illustrate the level of capability available for C++. You'll find similar technology available for other languages but not VBA...