VBA convert all elements to brep

Hi all,

Does anyone know a method to convert elements from a feature / parametric solid to a simple smart solid in VBA? I know you can achieve this through a keyin with cadinputqueue.sendkeyin "convert brep" however I need to do this programmatically in vba so that I can process elements in a separate file as part of an Application.opendesignfileforprogram(filename, false) script

Thanks in advance!

Ed

  • I know you can achieve this through a keyin with cadinputqueue.sendkeyin "convert brep"

    The safest way would be to use that key-in.

    Does anyone know a method to convert elements from a feature / parametric solid to a simple smart solid in VBA?

    Not sure what a simple smart solid is.  SmartSolid.ConvertToSmartSolidElement was introduced with MicroStation CONNECT Update 10.  Help has this caveat: Not all type of element can be converted to SmartSolidElement.

     
    Regards, Jon Summers
    LA Solutions

  • Hi Jon,

    I can't seem to get the element to be converted to a smart solid from element type "106" (parametric solid), using the  SmartSolid.ConvertToSmartSolidElement  function?

    I discovered that the drop element command through the microstation UI works for dropping the element to a smartsolid when 'application elements' is ticked; unfortunately this function doesn't seem to be supported directly in vba through the element.drop command, which would have allowed me to use it when opening a file through  Application.opendesignfileforprogram

    Do you know of any mdl functions I could implement through a wrapper to achieve this operation?

    Thanks,


    Ed

  • Hi Ed,

    can you share more details about your environment and the context?

    In MicroStation different solid types (and implementations how the data is stored) have been used historically and even more, MicroStation CONNECT Edition makes plenty of them obsolete. So to know what MicroStation version you use would help. Another question is what do you mean by "feature / parametric solid" you mentioned in your original question. I am confused a bit here, because "feature modeling" is V8 technology, but "parametric solid" sounds more like CE feature.

    You should be aware about these facts:

    • There is probably no universal way how to convert one solid type into another. Usually simpler solid can be converted into complex one (e.g. solid to smart solid), but not vice versa.
    • In my opinion the only target element type, that is able to "cover" anything, is mesh, because any type of solid or surface can be meshed (simplified to facets).
    • What is available in MicroStation in a form of tools or key-ins is not equal to internal MicroStation APIs, often the tools are formed by complex code implemented on top of API (and as such this functionality is not avaialble to 3rd party developers).
    • VBA API offers quite limited support for 3D elements and operations. It has been enhanced step by step in V8i versions and also in CE (so to know used version is important), but still it's not very powerfull.
    I know you can achieve this through a keyin with cadinputqueue.sendkeyin "convert brep"

    I agree with Jon to use key-in is the safe way.

    I can't seem to get the element to be converted to a smart solid from element type "106" (parametric solid)

    Type 106 is not parametric solid type! Sometimes in V8i (e.g. when exported to i-model) and often in CONNECT Edition, types 106 and 107 are used. Type 106 is "extended element" and type 107 is "extended nongraphic element". These types tell you nothing about the element itself and you need API to interpret it (which is in parallel with CE API concept to don't take care about data storage and use element handlers to access elements). Type 106 can be parametric solid, but it can be also other complex element not supported directly by DGN V8 format.

    which would have allowed me to use it when opening a file through  Application.opendesignfileforprogram

    Maybe this scenarios is not supported. OpenDesignFileForProgram has some limitations, because not all MicroStation features / modules are initialized (I remember discussions about rasters).

    Do you know of any mdl functions I could implement through a wrapper to achieve this operation?

    In what MicroStation version? In CE, plenty of functionality was moved to C++ API, so there are no wrappers to VBA available, and for old MDL functions, the wrappers are not described (so it requires some extra research and testing).

    With regards,

      Jan

  • can't seem to get the element to be converted to a smart solid from element type "106" (parametric solid), using the  SmartSolid.ConvertToSmartSolidElement  function?

    It's hard to diagnose a problem without seeing some code.  What does the  type 106 look like?  How was the type 106 created?

     
    Regards, Jon Summers
    LA Solutions

  • Hi Jon,

    It was created with AECOsim building designer (Connect edition), as a parametric solid. I have got the script running fine now doing just the essential cadinputqueue processing within a temp model of the active file, then the remainder of the process is carried out in opendesignfileforprogram. It would have been nice to make it even more efficient, however it does the job and it seems that I am butting up against the limitations of VBA yet again!

    Do you know of any good resources for learning MDL / Interfacing with the API? I have downloaded the SDK but not sure where to get started. Have done some (limited) C++ programming so hopefully that comes in handy
    Thanks for all the help,


    Ed

  • Hi Jan,

    Thanks for the reply, I am working in Aecosim CE. I got the script running using the key-in method in the activedesignfile before exporting the revised geometry, which is not very efficient but at least it gets the job done! It seems that vba once again doesn't support the functionality needed... I have to get around to learning the new API. Do you know of any good resources to get started with this?

    BTW yes you are correct type 106 is extended element; I was just trying to get across was that the specific elements I am processing are parametric solids ;)

    Thanks for all the help, much appreciated.


    Ed

  • Do you know of any good resources for learning MDL

    MDL is sooo 20th century, but it remains useful for MicroStation V8i development, less so for CONNECT development.  The MicroStationAPI is C++ but for MicroStation V8i development is useful though incomplete (MDL still required).

    Have done some (limited) C++ programming

    MicroStation development is complex.  It requires a combination of procedural programming (MDL), object-oriented programming (MicroStationAPI) and text-based resource design (command tables, dialogs, message lists) all without an Interactive Design Environment (IDE) that people have come to expect through using IDEs such as VBA and Viz Studio.

    It seems that vba once again doesn't support the functionality needed... I have to get around to learning the new API

    There's no guarantee that switching API will lead to a fruitful conclusion.  Type 106 elements are opaque: you know that you have one, but you can't see inside it, using any API.  Those types of elements require an application-specific handler, whether the application be MicroStation or AECOSim.

    If you want an element type that you can handle, consider a mesh element.  The C-style APIs have extensive coverage of mesh elements, VBA has SmartSolid.FacetSolidAsMesh.

     
    Regards, Jon Summers
    LA Solutions

  • Hi Ed,

    I got the script running using the key-in method in the activedesignfile before exporting the revised geometry

    If you are interested in further reasearch, in my opinion you should to return back to an origin and to ask:

    • Is it ensured that every type 106 element (e.g. parametric solid created by AECOsim BD tools) can be converted to SmartSolid? I don't think it's possible, but I guess would be able to provide an insight.
    • Why do you need to convert parametric solids into SmartSolids, when it's a kind of data degradation? What do you need to achieve?
    • What limitations exist when DGN file is opened as work file (OpenDesignFileForProgram)?
    It seems that vba once again doesn't support the functionality needed

    Yes, it's often situation. VBA is scripting / macro tool, not very good to implement anything more complex. Even more, 3D elements support has always been very limited. And when we talk about CE development, in my opinion VBA will survive as simple users oriented tool only, because C++ and NET APIs are designed in very different way (they have changed substantially comparing to V8i).  Contrary to it, VBA still uses the same object model as in V8i (which is good for users and hobby developers).

    I have to get around to learning the new API

    It's up to you what to choose and where to start: C++ is powerfull, but not very user friendly and pretty hard to learn. And you have to study and understand a huge amount of things including how to create make files etc. For advanced "3D oriented" code it is the best way, but a question is whether such investment makes sense for you.

    There is an alternative in NET API (so C# would be the choice here), which is new (it did not exist in V8i). Despite of it provides less functionality than C++ API, is not so well documented and is probably a bit slower, it's still very powerfull.

    Do you know of any good resources to get started with this?

    There are no resources in my opinion. The best is MicroStationAPI help file delivered with SDK, which provides plenty of valuable information, but sometimes it's hard to find it and it's not learning guide. Even though it's C++ doc, it's usefull also for NET, because NET API doc is not complete yet and in such case C++ description can help, because both APIs share similar concepts.

    Usually it's recommended to start with some example delivered with SDK and try to understand how it's build (C++ using bmake outside Visual Studio, NET usually using MSBuild from Visual Studio) and how it works.

    BTW Concepts introduced in CE APIs are very different from how VBA works.

    With regards,

      Jan

  • Do you know of any good resources for learning MDL

    Perhaps some training or an MDL workshop?  Where are you located (your bio is empty)?

     
    Regards, Jon Summers
    LA Solutions

  • I'm located in Melbourne, Australia... Would be great to do a workshop if something like that exists, but support here is limited so I will likely have to follow online resources. You gave me a good idea though and I found that there is a Bentley learn course and also a SIG workshop for learning the SDK, so I will start working through all that as an introduction.

    Thanks for all the advice,

    Ed