OpenPlant - Create Area - Programatically set the parameters

Hello,

I need to programatically call Create Area (Under Plant Areas) for several solids.

I found this command MECHADDIN MAKEVOLUME PLANT_AREA and also the underlying APIs Bentley.Building.Mechanical.CreateAreaFromSolid(...)

However a screen appears asking to set several parameters. How can I avoid  the screen and set the params programmatically?

Aldo

  • After digging into Bentley dlls with ILSpy and windbg-ing I found a possible solution.

    It does not open the window for user to set parameters because MyVol has set the property Name.

    When this is not null or empty then the logic insiede Bentley.Building.Mechanical.CreateAreaFromSolid(...) does not rasie the window

    MyVol bb = new MyVol(locale._elementoLocale);

    bb.CreateSolid();

    List<Bentley.Building.Mechanical.VolumeDefinitions.IVolumeDefinition> volDefs = new List<IVolumeDefinition>();

    volDefs.Add(bb);

    Bentley.Building.Mechanical.MechAddIn.CreateAreasFromVolumeDefinitions("PLANT_AREA", volDefs);

    Where MyVol  is

    public class MyVol : BaseVolumeDefinition

    {

    SmartSolidElement _solid;

    public MyVol(Element element)

    {

    _solid = Utilities.ComApp.SmartSolid.ExtrudeClosedPlanarCurve(element, 1000, 1000, false);

    this.Name = "aaa1111"; // will avoid to open the form

    this.VolumeType = Bentley.Building.Mechanical.VolumeDefinitions.VolumeType.Undefined;

    Utilities.ComApp.ActiveModelReference.AddElement(_solid);

    Utilities.ComApp.RedrawAllViews(MsdDrawingMode.Normal);

    }

    public override int CreateSolid()

    {

    return _solid.MdlElementRef();

    }

    }

    Answer Verified By: JustinasL 

  • Hello Aldo,

    Thanks for sharing the solution here, it might be useful for some other users. I've marked this question as answered. If you have some additional queries do not hesitate to post it.

    Regards,

    Justinas