I'm looking for a way to offset dimensions quick and easy.
How would I accomplish this task?
Have VBA read active scale
Multiply active scale by .375 (set distance)
Move selected dimension (set distance) from picked point
Activate command again
Any help would be greatly appreciated.
to be able to identify an element, you have to implement own ILocateCommandEvents object. There are some examples available in MicroStation VBA help.
I am not sure whether I understand the required dimension modification right, but a position of dimension text and line is defined as a distance from dimension reference point. In VBA API it's DimensionElement.DimHeight, so if you want to move the text and line, I suppose you should modify this value.
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
I've been messing with this all day and cant make any headway. I'm new to VBA too, so that doesn't help.
I cant get the DimensionElement.DimHeight to work at all. It errors out everytime.
This is what I have so far and it errors out at DimHeight.
Dim oDim As DimensionElement
Dim oScale As Integer
Dim oDimSpace As Integer
oScale = 32
oDimSpace = oScale * 0.375
.DimHeight = oDimSpace
Im also having a hard time figuring out how to select the dimension after the macro is activated.
I'm guessing its something along the lines of:
Set oDim = ActiveModelReference.GetSelectedElements
But that errors out too.
Can someone get me on the right path?
Jonathan N said:I'm new to VBA too, so that doesn't help.
I recommend to read Learning MicroStation VBA book, sold both by Bentley and Amazon. Regardless it's quite old, it's still valid and one from benefits is that it contains both VBA basic and learning of MicroStation VBA API ... which is a mistake done often by beginners to start work with MicroStation VBA API without knowledge of VBA language itself.
Jonathan N said:I cant get the DimensionElement.DimHeight to work at all. It errors out everytime.
What does it mean? What is reported error.
Looking at your code, I don't see any oDim assignment to existing instance, so the code cannot work for sure.
Jonathan N said:Set oDim = ActiveModelReference.GetSelectedElements
It cannot work or it's better to say it can in some cases, but it's not correct. Selection set can contain any set of graphical elements (different element types), but oDim variable can point to one instance of Dimension Element only.
Jonathan N said:Im also having a hard time figuring out how to select the dimension after the macro is activated.
I wrote it already: You have to implement ILocateCommandEvents object. It ensures VBA code behaves similarly to standard MicroStation location tools including correct support of data and reset mouse buttons. There are examples in MicroStation VBA help how to implement this class. Did you read them?