Greetings,
I'm building on others' work in Connect to get the clip boundary for a reference file. I am using VBA to do this by calling a couple of MDL functions.
The end result is I have a pointer to a ref file structure. I'm trying to use the GetCExpressionValue() function to retrieve values in the ref file structure.
in V8i it was apparently acceptable to use:lngScale = GetCExpressionValue((struct referenceFile *)2250204734080)->display.scale)
However, in Connect it's throwing an error, "structure/union names expected". I assume this means it can't find the referenceFile structure at that pointer address or the method for passing the address has changed in the GetCExpressionValue function.
Any ideas?
Thank you.
Perhaps a better question is, what is a valid MDL expression in Connect equivalent to the value at
((struct referenceFile *)2250204734080)->display.scale
Scott T Anderson said:in V8i it was apparently acceptable to use:lngScale = GetCExpressionValue((struct referenceFile *)2250204734080)->display.scale)
lngScale = GetCExpressionValue((struct referenceFile *)2250204734080)->display.scale)
When was that ever acceptable? What that does is to attempt to find the value of a hard-coded address (2250204734080), cast it to a referenceFile pointer, and get the at the specified address. It's a very fragile construct. I'm astonished if that worked repeatably in MicroStation V8i.
2250204734080
referenceFile
Scott T Anderson said:Perhaps a better question is, what is a valid MDL expression in Connect
A much better question. What about VBA's Attachment.ScaleFactor?
Attachment.ScaleFactor
Scott T Anderson said:I'm building on others' work in Connect to get the clip boundary for a reference file
Here are some suggestions.
Regards, Jon Summers LA Solutions
Hi Scott,
Scott T Anderson said:in V8i it was apparently acceptable to use:
I agree with Jon: The code you shared is very close to nonsense and it's a miracle it worked.
Scott T Anderson said:Perhaps a better question is, what is a valid MDL expression in Connect equivalent to the value at
I think better would be to explain what do you want to achieve and to write the new code from scratch. I doubt there is any reason to use CExpression, probably to use a combination of MicroStation VBA API (like Attachment object mentioned by Jon) and calling C functions is better way.
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Thanks gents. I am trying to find existing clip boundary vertices and move the clip boundary a set distance. I can use VBA's native function to re-clip on new vertices. However, I cannot get the original clipping vertices through VBA. I need to enumerate each ref attachment, find the clip boundary and clip mask vertices and re-clip at a fixed new distance/direction from original points. MDL is a non-starter, I don't have time to go back and start compiling MDL's again. Ideas appreciated!
Scott T Anderson said:However, I cannot get the original clipping vertices through VBA.
Yes, it's right that clip / mask information is missing in MicroStation VBA and it was discussed many times.
Scott T Anderson said:I need to enumerate each ref attachment, find the clip boundary
I think the only way is to call mdlClip_getRefBoundary native function. You can find several discussions about this topic (e.g. this one).
A threat I see is that ClipVector object is returned, which is probably not simple to be interpreted in VBA.
Scott T Anderson said:MDL is a non-starter, I don't have time to go back and start compiling MDL's again.
One from crucial rules in development is "use the right tool". When there is no support for clipping in VBA, it means VBA is not right tool. I would not be surprised when to write such functionality e.g. in C# would be faster than to find a right way how to obtain clip data from native to VBA API, analyze it and to move a reference accordingly.
Scott T Anderson said:I am trying to find existing clip boundary vertices
The C++ API has changed with CONNECT compared to V8i. It's more object-oriented. The way to get clip points using C++ is...
DgnAttachment
DgnAttachment.GetClipBoundaries()
ClipVectorPtr
Unfortunately for you, there's no simple way for VBA to use those C++ classes.
Scott T Anderson said:I don't have time to go back and start compiling MDL's again
MicroStation CONNECT's C++ MicroStationAPI is mostly class-based and most of the old MDL functions have moved into C++ classes. MDL — an interpreted pseudo-code C-style language — died with MicroStation V8i.
Both the C++ MicroStationAPI and the new .NET API have classes with methods that do what you want.
I may be able to leverage .Net to do this. I won't be able to get a C++ dev environment. Thanks very much gents for giving me some direction on this! I may have more questions but this has been very helpful.
Scott..
Scott T Anderson said:I may be able to leverage .Net to do this. I won't be able to get a C++ dev environment.
In my opinion, MicroStation NET API is a good balance between C++ API (which is powerful, but C++ is complicated) and COM / VBA API (simple, but very limited).
You can even choose VB.NET as NET language (when there is NET variant of particular language, you can use it to write code for MicroStation ;-), but I do not recommend it. VB.NET is not very actively developed and is not widely used, so to obtain help is more difficult than for C#, that is used everywhere (so there are many tutorials about C# itself available).
Regards,