Hello
In general, can we modify built in commands using VBA? I try to explain what I mean on two commands that I would like to have in Microstation.
1. Drawing a line at a slope.
2. Annotate/Measure the slope of a line.
Both commands are almost available in Microstation and I would like to make just a slight change.
For first command:
1. Instead of defining angle for command place line. I want to define slope (1:x) or percentage (5%).
So I hope, that there is an option to make simple macro that modifies (do preliminary step) the command place a line at angle as follows. Macro opens a form similar to that below where user define his input and based on format a function in the macro calculates the angel that is send to build in command place a line at angle. The user would picked 2 points while accudraw and snap modes available and it's done.
Picture might ilustrate my idea.
For second command:
2. Instead of labeling line with angle (element dimensioning -> label line). I want to label it with 1:x or 5%.
Replace angle by 1:xx or xx%
In this case we just need to multiply the value by right number (calculated in macro) and add prefix or suffix. It would remain associative.
Are both cases possible for ordinary users or it is somehow protected and only bentley's developers can do this slight changes?
I appologize if my question is too silly because I am a total VBA and Microstation beginer.
Tom
Tomáš Prokš said:Can we modify built in commands using VBA?
Sometimes it's possible to adjust the settings of a command. Use the VBA macro recorder to create a macro while you start, adjust, and finish a built-in command. The recorded macro may reveal the application variables of the command.
Once you know the application's variables it may be possible to change them programmatically.
Regards, Jon Summers LA Solutions
Hi Tomáš,
Tomáš Prokš said:In general, can we modify built in commands using VBA?
Generally ... no. MicroStation philosophy from its beginning is to provide API to build own (new) tools, not to modify existing ones.
As Jon wrote, some (basic, but often useful) interaction is possible: Nearly all tools (exceptions exist) allows to set their parameters (switches, text values etc.). Typically "set item toolsettings" key-in can be used for this purpose, but sometimes to record VBA macro is the right way.
Tomáš Prokš said:Instead of labeling line with angle (element dimensioning -> label line).
I think when you want to display another value than the default one, you cannot use this tool, because it's hard coded. But it's possible to place normal text, aligned with the line.
Tomáš Prokš said:and only bentley's developers can do this slight changes?
All "developers' tools" are aim to create own tools. If I understand your question right, you want to place line at slope (one data point is required) and in the next step, to place text with the slope information, which can probably be done automatically. VBA should be able to handle it.
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Hi Jon and Jan,
thank you for navigating to right direction.
I have tried your advices. it might be beginners luck, but step by step and with help from a book my basic macro can draw a line and place text. However, I strugle with making text associative. Is my idea right, that for this I would need to use classes, property, events? Right now, unknown area for me.
T.
Tomáš Prokš said:I struggle with making text associative
You will continue to struggle, because VBA does not have the appropriate classes to create associative text. With MicroStation CONNECT, you can use the .NET DgnPlatformNet or C++ MicroStationAPI classes. With MicroStation V8i, you need the C++ MicroStationAPI.
This is a dead end for me :-). Thank you for information so I will not waste my time.
You can go old school and assign the two elements to the same graphic group in vba. When you activate the Graphic Group lock they will act as if they are associated.
Rod WingSenior Systems Analyst
Thanks Rod for a hint.