Several helper objects can be created with the Advance Steel API.
This walkthrough will explore various helper objects that can be useful when modeling in Advance Steel.
This tutorial assumes you have a new Advance Steel addin project called MiscellaneousObjects with one class file that implements the IExtensionApplication interface.
Create a new class called Commands and add the following using statements:
|
Code Region: Commands class |
using Autodesk.AdvanceSteel.BuildingStructure;
using Autodesk.AdvanceSteel.CADAccess;
using Autodesk.AdvanceSteel.ConstructionHelper;
using Autodesk.AdvanceSteel.DocumentManagement;
using Autodesk.AdvanceSteel.Geometry;
using Autodesk.AdvanceSteel.Modelling;
using Autodesk.AdvanceSteel.Runtime;
namespace MiscellaneousObjects
{
class Commands
{
}
}
|
This tutorial will include multiple commands for adding different types of helper objects to a model. Note that each method in the commands class needs to have the CommandMethodAttribute which assigns a unique name to the command, and the method must be public.
Model views are local areas from the 3D model that display only objects within the defined space. This can improve work speed in large structures by isolating only certain parts of the model.
The following method demonstrates how to create a new ModelViewObject and set its visibility. The ModelView uses clipping planes to clip the visibility of objects in the view and the BuildingStructureFunctionalities.updateClips() method is called to trigger a graphics update. By passing a 1 for the parameter, the view direction will also be changed. If a 0 is passed, only the clipping planes are activated.
|
Code Region: Creating a model view |
[CommandMethodAttribute("TEST_GROUP", "CreateModelView", "CreateModelView", CommandFlags.Modal | CommandFlags.UsePickSet | CommandFlags.Redraw)]
public void CreateModelView()
{
DocumentManager.lockCurrentDocument();
TransactionManager.startTransaction();
BuildingStructureManager bsMan = BuildingStructureManager.getBuildingStructureManager();
ModelViewObject modelView = ModelViewObject.create(bsMan.CurrentBSO.ModelViewsTreeObject, "newModelView", Matrix3d.kIdentity, 1, 500, 1, 500, 1, 500, 1, 500, 1, 500, 1, 500);
modelView.ModelViewBoxVisibility = 1;
BuildingStructureFunctionalities.updateClips(1);
TransactionManager.endTransaction();
DocumentManager.unlockCurrentDocument();
}
|
You can also use the API to get an existing ModelViewObject and change its properties, including whether it is visible or not.
|
Code Region: Hiding a model view |
[CommandMethodAttribute("TEST_GROUP", "HideModelView", "HideModelView", CommandFlags.Modal | CommandFlags.UsePickSet | CommandFlags.Redraw)]
public void HideModelView()
{
DocumentManager.lockCurrentDocument();
TransactionManager.startTransaction();
BuildingStructureManager bsMan = BuildingStructureManager.getBuildingStructureManager();
ModelViewObject modelView = (ModelViewObject)bsMan.CurrentBSO.ModelViewsTreeObject.GetStructureItem("newModelView");
modelView.ModelViewBoxVisibility = 0;
BuildingStructureFunctionalities.updateClips(0);
TransactionManager.endTransaction();
DocumentManager.unlockCurrentDocument();
}
|
Levels (or stories) are used to create a slice through the structure at a specified height. This simplifies the modelling of multilevel structures by controlling the visibility of structural elements. Levels are a particular type of model view and, like model views, clip the objects visibility when activated. Note that new objects are automatically placed on the active level.
In the CreateLevels() method below, 3 new levels are created. The first two levels are created using the LevelObject.Create() method, while the third level is created using BuildingStructureFunctionalities.copyLevelBelow() to copy an existing level to a new height. To demonstrate how objects are added to the active level, after each level is created, it is set as the current (active) level and a new beam is added to the model which will be associated with that level. After each beam is created, the ModelView visibility is set to 1 for the LevelObject. This makes the level visible in the view.
|
Code Region: Adding Levels |
[CommandMethodAttribute("TEST_GROUP", "CreateLevels", "CreateLevels", CommandFlags.Modal | CommandFlags.UsePickSet | CommandFlags.Redraw)]
public void CreateLevels()
{
DocumentManager.lockCurrentDocument();
TransactionManager.startTransaction();
BuildingStructureManager bsMan = BuildingStructureManager.getBuildingStructureManager();
LevelObject level1 = LevelObject.Create(bsMan.CurrentBSO.LevelTreeObject, "Level 1", 0, null, null);
// Set the current level to the newly created level
bsMan.CurrentBSO.CurrentLevel = level1;
// New beams will be added to the active level
Beam beam1 = new StraightBeam("HEA DIN18800-1#@§@#HEA100", new Point3d(0, 0, 0), new Point3d(2000, 0, 0), new Vector3d(0, 0, 1));
beam1.WriteToDb();
LevelObject level2 = LevelObject.Create(bsMan.CurrentBSO.LevelTreeObject, "Level 2", 5000, null, level1);
bsMan.CurrentBSO.CurrentLevel = level2;
Beam beam2 = new StraightBeam("HEA DIN18800-1#@§@#HEA200", new Point3d(0, 0, 5000), new Point3d(2000, 0, 5000), new Vector3d(0, 0, 1));
beam2.WriteToDb();
level2.ModelView.Visible = 1;
// New levels can also be added by copying other levels
LevelObject level3 = BuildingStructureFunctionalities.copyLevelBelow(level2, "Level 3", 10000);
bsMan.CurrentBSO.CurrentLevel = level3;
Beam beam3 = new StraightBeam("HEA DIN18800-1#@§@#HEA300", new Point3d(0, 0, 10000), new Point3d(2000, 0, 10000), new Vector3d(0, 0, 1));
beam3.WriteToDb();
level3.ModelView.Visible = 1;
BuildingStructureFunctionalities.updateClips(0);
TransactionManager.endTransaction();
DocumentManager.unlockCurrentDocument();
}
|
Detailers can use cameras to specify detailing areas with custom depths within the model and to assign specific detail styles and scales. The following example adds a new Camera and sets the type to Anchor plan. Other options for the type are "none", "Intersection", "Node", "Overview", and "Roof" (for Roof plan).
|
Code Region: Creating a camera |
[CommandMethodAttribute("TEST_GROUP", "CreateCamera", "CreateCamera", CommandFlags.Modal | CommandFlags.UsePickSet | CommandFlags.Redraw)]
public void CreateCamera()
{
DocumentManager.lockCurrentDocument();
TransactionManager.startTransaction();
Camera cam = new Camera(Matrix3d.kIdentity);
cam.CameraType = "Anchor";
cam.WriteToDb();
TransactionManager.endTransaction();
DocumentManager.unlockCurrentDocument();
}
|
The following method creates a new work area with a detail level of Medium for entities outside the work area.
|
Code Region: Creating a work area |
[CommandMethodAttribute("TEST_GROUP", "CreateWorkArea", "CreateWorkArea", CommandFlags.Modal | CommandFlags.UsePickSet | CommandFlags.Redraw)]
public void CreateWorkArea()
{
DocumentManager.lockCurrentDocument();
TransactionManager.startTransaction();
WorkArea workArea = WorkArea.GetWorkArea(DocumentManager.getCurrentDocument().CurrentDatabase, 1);
workArea.Set(new Point3d(0, 0, 0), new Point3d(1000, 1000, 1000), WorkArea.eLevelOfDetail.kMedium);
workArea.Refresh();
TransactionManager.endTransaction();
DocumentManager.unlockCurrentDocument();
}
|