Is it possible to place a wall by a vba-macro?
Something like... Set MyLine = Application.CreateLineElement2(Nothing,StartPoint, EndPoint) Application.ActiveModelReference.AddElement My Line...not for LineElements but for Walls.
Thank you very much for helping me.
After you reference TFCom and STFCom, you can place a wall by using VBA code. The following is a C# code and VBA code is very similar. you can refer to it.
Application msApp = Bentley.MicroStation.InteropServices.Utilities.ComApp; // defined in Bentley.MicroStation.dll STFWallList wallList = new STFWallList(); STFWall wall = wallList.AsSTFWall; TFFormRecipeLinearList formList = new TFFormRecipeLinearList(); TFFormRecipeLinear linearForm = formList.AsTFFormRecipeLinear; Point3d p = msApp.Point3dFromXYZ(50, 0, 0); Point3d q = msApp.Point3dFromXYZ(50, 20, 0); linearForm.SetEndPoints2(ref p, ref q); linearForm.SetThickness(0.5); linearForm.SetOffsetType(TFdFormRecipeOffsetType.tfdFormRecipeOffsetTypeCenter); linearForm.SetTopFixedHeight(5.0); wall.SetTFFormRecipeList((_TFFormRecipeList)formList); wall.InitNamedProperties("Wall", "Concrete"); _TFFormRecipeList recipeList = wall.GetTFFormRecipeList(); TFFormRecipe recipe = recipeList.AsTFFormRecipe; recipe.SetPartFamilyName("WallComponent"); recipe.SetPartName("Concrete"); wall.AddToDgn();
HTH, YongAn
Thanks a lot for your answer YongAn.
I am a vba beginner without c# experience so it would be really kind of you to check my vba code.
Sub Main()
Dim wallList As STFWallListDim wall As STFWallDim formList As TFFormRecipeLinearListDim linearform As TFFormRecipeLinearDim p As Point3dDim q As Point3dDim recipeList As TFFormRecipeListDim recipe As TFFormRecipe
Set wall = wallList.AsSTFWall Set linearform = formList.AsTFFormRecipeLinear p.X = 50 / p.Y = 0 / p.Z = 0 q.X = 50 / q.Y = 20 / q.Z = 0 linearform.SetEndPoints2 p, q linearform.SetThickness 0.5 linearform.SetOffsetType TFdFormRecipeOffsetType.tfdFormRecipeOffsetTypeCenter linearform.SetTopFixedHeight 5# wall.SetTFFormRecipeList formList wall.InitNamedProperties "Wall", "Concrete" Set recipeList = wall.GetTFFormRecipeList Set recipe = recipeList.AsTFFormRecipe recipe.SetPartFamilyName "WallComponent" recipe.SetPartName "Concrete" wall.AddToDgn
End Sub
Unknown said: How could I refer the TFCom and STFCom?
If you're writing VBA, then use the Tools|References menu in the VBA editor to pop the VBA References dialog. Then you can add the VBA libraries to your VBA project...
Regards, Jon Summers LA Solutions