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);
}