OpenBuildings VBA SheetNumber Model Property

Hello all,

I'm having the hardest time figuring out what OBD (v10.05.00.049) wants me to call the "Sheet Number" model property through VBA. I've set up a search criteria to scan all my tags in my drawing. When it gets to the drawing number tag, I want it to take that value and apply it to the model property "Sheet Number". It's not working for "SheetNumber", but if I replace "SheetNumber" with "Name" or "Description" it works as expected so I think the code it getting the definitions of "MyModel" correctly. Another odd thing is if I type "sheetnumber", the VBA editor capitalizes it to "SheetNumber", so I think it recognized it. Any help would be much appreciated. Thanks!

If Tag.TagDefinitionName = "drawing_number" Then
                MyModel.SheetNumber = Tag.Value
            End If

Amador

Parents
  • Hi Amador,

    I've set up a search criteria to scan all my tags in my drawing

    Not important for the discussion how to change the sheet parameters ;-)

    Another odd thing is if I type "sheetnumber"

    API naming and MicroStation GUI are different, I assume because of history and MicroStation features development. It can be confusing, but right "mapping" can be found easily.

    Any help would be much appreciated.

    This should work:

    Public Sub ChangeSheetParams()
    
        If ActiveModelReference.Type <> msdModelTypeSheet Then
            Exit Sub
        End If
        
        Dim sheetDef As SheetDefinition
        Set sheetDef = ActiveModelReference.GetSheetDefinition
        
        ' Set sheet number
        sheetDef.SheetName = "Whatever number"
        
        ' Set sequence number
        sheetDef.SheetNumber = 9999
        
        ' Save changes back to the sheet definition
        ActiveModelReference.SetSheetDefinition sheetDef
        
    End Sub

    With regards,

      Jan

    Answer Verified By: Amador Ontiveros 

  • Thank you for your reply Jan! I understand what you've presented but I'm starting to think the sheet number is part of a different definition in OpenBuilding. Notice the debugger highlighted ".SheetNumber" as the error.

    the debug highlights a part of the code that seems correct so I checked all the options for "MyModel" and notice "SheetNumber" is not included.

    Maybe this is a glitch in the version of OpenBuilding that I'm using, as my company has not upgraded to the latest build.

  • the sheet number

    Because of confusing naming (different in GUI and in API), I recommend to post picture what "sheet number" do you mean.

    is part of a different definition in OpenBuilding

    It cannot be, but I guess only the picture (I have not OBD installed) can confirm you mean "sheet number" from MicroStation and not "sheet number" used by OBD in different context. But I do not think it's the case.

    Notice the debugger highlighted ".SheetNumber" as the error.

    Of course it does. As Jon wrote, sheet number (as well as all other sheet properties) is not part of model data structure. It means you cannot access properties like sheet number, sheet name etc. using model reference (it just not makes sense). The right way, as demonstrated in my code, is to obtain SheetDefinition object at first.

    Maybe this is a glitch in the version of OpenBuilding that I'm using

    I am pretty sure it's not.

    Why do you not try my code, extract SheetDefinition, to change SheetName property (displayed as "Sheet number" in GUI) in this object and to assign it back to the model?

    With regards,

      Jan

  • Here is the image Jan

    Of course it does. As Jon wrote, sheet number (as well as all other sheet properties) is not part of model data structure. It means you cannot access properties like sheet number, sheet name etc. using model reference (it just not makes sense). The right way, as demonstrated in my code, is to obtain SheetDefinition object at first.

    If i change the code to

     

    If Tag.TagDefinitionName = "drawing_number" Then
                    MyModel.Description = Tag.Value
                End If

    It does write back to the "Description" column in the GUI, so I'm not sure I follow... I posted in my reply to Jon that I used ".GetSheetDefinition". I will start a new VBA session to test your code as is to see if it writes back.

    Thanks again for help with this!

Reply
  • Here is the image Jan

    Of course it does. As Jon wrote, sheet number (as well as all other sheet properties) is not part of model data structure. It means you cannot access properties like sheet number, sheet name etc. using model reference (it just not makes sense). The right way, as demonstrated in my code, is to obtain SheetDefinition object at first.

    If i change the code to

     

    If Tag.TagDefinitionName = "drawing_number" Then
                    MyModel.Description = Tag.Value
                End If

    It does write back to the "Description" column in the GUI, so I'm not sure I follow... I posted in my reply to Jon that I used ".GetSheetDefinition". I will start a new VBA session to test your code as is to see if it writes back.

    Thanks again for help with this!

Children