Dear All,
I am using v8 2004 Edition with VBA. i need to find out the Text Element Overlap using VBA any one give me the idea for find the text element overlap.
with Regards,
Karthik
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Hi jan,
Thanks for your comments. i am get the text element range and create polygon shape using range coordinates for get overlapping elements. but range coordinates exceed the text element. here i attached my vba code and sample dgn please find and give me the solution.
sub Test() dim ele as element Dim eleEnum As ElementEnumerator Set eleEnum = ActiveModelReference.GetSelectedElements While eleEnum.MoveNext Set ele = eleEnum.Current If ele.IsTextElement Then CreateRange ele End If Wend end sub private sub CreateRange(ele As Element) Dim verts(0 To 4) As Point3d Dim range As Range3d Dim pt1 As Point3d Dim pt2 As Point3d Dim shpele As Element range = ele.AsTextElement.range pt1 = range.High pt2 = range.Low verts(0).X = pt1.X verts(0).Y = pt1.Y verts(1).X = pt1.X verts(1).Y = pt2.Y verts(2).X = pt2.X verts(2).Y = pt2.Y verts(3).X = pt2.X verts(3).Y = pt1.Y verts(4) = verts(0) Set shpele = CreateShapeElement1(Nothing, verts, msdFillModeNotFilled) ActiveModelReference.AddElement shpele End Function
Testing.dgn
Unknown said:but range coordinates exceed the text element.
Yes, I wrote it's the rough method ... and rotated texts (rotated elements in general) naturally produce bigger range, because it's how the range is defined (min and max xyz coordinates).
If you want to receive more tight text envelope, you have to implement own algorithm. I guess basic concept is quite easy: unrotate the element, obtain its range and create the text envelope, rotate the envelope back accordingly to the text original rotation and to use it for the overlap test.
With regards,
Jan
Hi,
unrotate the element, obtain its range and create the text envelope
How to Unrotate the Element can you me the sample code for unrotate element.
Karthik M
Unknown said:can you me the sample code for unrotate element.
Frankly ... no ... you want to be developer so act as developer and investigate own solution (despite of it takes a lot of time at the beginning) and don't compose pieces of code written by somebody else. Especially if it's about very basic topic, which can be treated as mandatory for MicroStation development. Try to turn your every question "I need ... how to...?" (which is very often just a dedication of thinking process to somebody else) to "Why this part of my code doesn't work?".
Unknown said:How to Unrotate the Element
Elements like texts or cells have rotation property (Matrix3d), so it's easy to obtain rotation abouz Z and use inverse angle to rotate the element back. My current feeling is that is easier for you to write the question than to open MicroStation VBA help and search for "text rotation" and think about results.
I apologize for a bit negative answer, it seems I am in a severe mood today, but I prefer to spend my free time to thinking why some code doesn't work and how to make it better than explaining what is available on Internet already.
Unknown said:but i did't get exact reference material
I don't understand what do you mean. Why do you expect there should be anything exactly related to a problem or issue you are solving?
There is MicroStation VBA help that provides pretty detail description of API including many examples. Thinking about topic "rotate element", there are plenty of sites (Wikipedia, Khan Academy, university webs etc.) explaining vector algebra and using matrices math for rotation, movement etc. This knowledge is absolutely mandatory and "must to know" before any piece of the code in any language for any CAD or GIS is written. And to be developer is to be able to merge general knowledge (vector, matrices...) with own investigation, apply it to to-be-solved problem and using knowledge of API to write a code.
Typically no "exact reference material" is available, but many quite close materials and discussions can be found. I tried to seach for "VBA rotate element" at this web and obtained long list of discussions, some even incuding MicroStation VBA code, about rotating different types of elements. This is where you have to start your learning (of course after learning vector and matrix math).
hi,
I don't understand what do you mean
Actually i am asking about Microstation vba reference book not only for the rotation of element . i want learn microstation vba that's why i am asking any reference book name or website.
with regards,
Karthik m.
Unknown said:Actually i am asking about Microstation vba reference book not only for the rotation of element .
It's better formulated question ;-)
The only book I know is Learning MicroStation VBA book from Jerry Winter (available on Bentley Press or Amazon). This is not bad, especially because it covers both VBA basics and MicroStation VBA APIs and a lot of code snippets. Of course it does not cover everything and in my opinion it's pretty "user oriented" without information about details, concepts etc. ... but maybe because of that it's better for beginners.
If supplemented with information from MicroStation VBA help and discussions in this forum, you will be able to learn MicroStation VBA in details. Of course Jon Summers' articles have to be mentioned also!
In my opinion all these source missed important topic: How to write good and clean code, which is not about to use proper VBA functions and constructions, but about code structure, naming, styles etc. But it's the study and learning for the whole life, based on reading code from other people and think about it.