Samples codes for Beams creation

Samples codes for Beams creation

tiago.pereiraGB2J9
Enthusiast Enthusiast
780 Views
3 Replies
Message 1 of 4

Samples codes for Beams creation

tiago.pereiraGB2J9
Enthusiast
Enthusiast

Hi,

 

Does everyone has an example code in VBA that builds a beam?

 

Thanks so much

0 Likes
781 Views
3 Replies
Replies (3)
Message 2 of 4

Ed__Jobe
Mentor
Mentor
I assume you mean a wide flange or similar beam? If you install the Plant 3D solution, I believe it comes with it. You didn't say if you wanted that 3D or not.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 3 of 4

tiago.pereiraGB2J9
Enthusiast
Enthusiast

hi @Ed__Jobe ,

 

I want to automate the creation of 3D beams, with VBA code. I saw that´s possible with Visual Studio, using C++, but i want to know if there´s any repository of VBA codes that do the same. 

 

I´m attaching an example of C++ code, that´s modeling a beam. Do you know if it´s possible to have the same code in VBA, like a translation only? 

 

Thanks so much!

private void CreateStraightBeam(ref AstObjectsArr createdObjectsArr)
{
//get default profile
string angleSection, angleSize;
getDefaultProfile(0, "HyperSectionW", out angleSection, out angleSize);
//create role object
IRole beamRole = m_Joint.CreateRole("Beam");
//create joint transfer
IJointTransfer jointTransfer = m_Joint.CreateJointTransfer("Beam");
//set some attributes
setJointTransferForBeam(ref jointTransfer, eClassType.kBeamStraightClass);
IPoint3d startPoint = (IPoint3d)(new DSCGEOMCOMLib.Point3d());
IPoint3d endPoint = (IPoint3d)(new DSCGEOMCOMLib.Point3d());
startPoint.Create(0, 0, 0);
endPoint.Create(0, 0, 500);
IVector3d zAxis = (IVector3d)(new DSCGEOMCOMLib.Vector3d());
zAxis.Create(0, 1, 0);
ICS3d inputCS = (ICS3d)(new DSCGEOMCOMLib.CS3d());
inputCS.XAxis = startPoint.Subtract(endPoint);
inputCS.ZAxis = zAxis;
//create a straight beam
//Function will use z axis from input CS and input points to create beam CS
//xAxis = vector from input points (startPoint.Subtract(endPoint))
//yAxis = zAxis.CrossProduct(xAxis) (zAxis from CS)
//zAxis = xAxis.CrossProduct(yAxis)
IStraightBeam straightBeam = m_Joint.CreateStraightBeam(angleSection, angleSize, 
(AstSTEELAUTOMATIONLib.Role)beamRole, startPoint, endPoint, inputCS);
//Add beam to created object array
if(straightBeam != null)
{
 straightBeam.JointTransfer = (AstSTEELAUTOMATIONLib.JointTransfer)jointTransfer;
 createdObjectsArr.Add(straightBeam);
}
}
//Get the default profile from the database (default profiles are set in the GAM)
private void getDefaultProfile(int defaultClass, string className, out string sectionClass, out string
sectionSize)
{
sectionClass = "";
sectionSize = "";
IOdbcUtils tableUtils = (IOdbcUtils)(new DSCODBCCOMLib.OdbcUtils());
string sSectionProf = tableUtils.GetDefaultString(defaultClass, className);
string separator = "#@" + '§' + "@#";
string[] section = sSectionProf.Split(new string[] { separator }, StringSplitOptions.None);
if (section.Length == 2)
{
 sectionClass = section[0];
 sectionSize = section[1];
}
}
//Create the JointTransfer for a beam
private void setJointTransferForBeam(ref IJointTransfer jointTrans, eClassType classType)
{
jointTrans.ClassType = classType;
/set here all the properties which can be modified outside the joint
jointTrans.set_Attribute(eAttributeCodes.kBeamDenotation, 1);
jointTrans.set_Attribute(eAttributeCodes.kBeamMaterial, 1);
jointTrans.set_Attribute(eAttributeCodes.kBeamCoating, 1);
jointTrans.set_Attribute(eAttributeCodes.kBeamSinglePartNumber, 1);
jointTrans.set_Attribute(eAttributeCodes.kBeamMainPartNumber, 1);
jointTrans.set_Attribute(eAttributeCodes.kBeamSinglePartPrefix, 1);
jointTrans.set_Attribute(eAttributeCodes.kBeamMainPartPrefix, 1);
jointTrans.set_Attribute(eAttributeCodes.kBeamAssembly, 1);
jointTrans.set_Attribute(eAttributeCodes.kBeamItemNumber, 1);
jointTrans.set_Attribute(eAttributeCodes.kBeamSinglePartDetailStyle, 1);
jointTrans.set_Attribute(eAttributeCodes.kBeamMainPartDetailStyle, 1);
jointTrans.set_Attribute(eAttributeCodes.kBeamNote, 1);
jointTrans.set_Attribute(eAttributeCodes.kBeamSPUsedForCollisionCheck, 1);
jointTrans.set_Attribute(eAttributeCodes.kBeamSPUsedForNumbering, 1);
jointTrans.set_Attribute(eAttributeCodes.kBeamSPDisplayRestriction, 1);
jointTrans.set_Attribute(eAttributeCodes.kBeamSPExplicitQuantity, 1);
jointTrans.set_Attribute(eAttributeCodes.kBeamMPUsedForCollisionCheck, 1);
jointTrans.set_Attribute(eAttributeCodes.kBeamMPUsedForNumbering, 1);
}

 

0 Likes
Message 4 of 4

Ed__Jobe
Mentor
Mentor

That code is C# and relies on having Advance Steel installed. The manual says it's a COM api. Perhaps you could reference that api type library in VBA. I don't know if it would work though, since I don't have it. I use Inventor for steel. Plain VBA doesn't have anything like that though. I still recommend using Plant 3D for stock parts usable in AutoCAD. You don't need to program anything. Just use it.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes