internal RectangularAnchorPattern(SteelGeometry.Point3d astPoint1, SteelGeometry.Point3d astPoint2, IEnumerable <string> handlesToConnect, SteelGeometry.Vector3d vx, SteelGeometry.Vector3d vy, List <Property> anchorBoltData, int boltCon) { lock (access_obj) { using (var ctx = new SteelServices.DocContext()) { Autodesk.AdvanceSteel.Modelling.AnchorPattern anchors = null; string handle = SteelServices.ElementBinder.GetHandleFromTrace(); var astPointRef = astPoint1 + (astPoint2 - astPoint1) * 0.5; if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null) { anchors = new Autodesk.AdvanceSteel.Modelling.AnchorPattern(astPoint1, astPoint2, vx, vy); SetAnchorSetOutDetails(anchors, astPoint1 + (astPoint2 - astPoint1) * 0.5, Autodesk.AdvanceSteel.Arrangement.Arranger.eArrangerType.kBounded); double aLengthX = Utils.GetRectangleLength(astPoint1, astPoint2, vx); // / (anchors.Nx - 1); double aLengthY = Utils.GetRectangleLength(astPoint1, astPoint2, vy); // / (anchors.Ny - 1); anchors.SetArrangerLength(aLengthX, 0); anchors.SetArrangerLength(aLengthY, 1); Utils.SetParameters(anchors, anchorBoltData); anchors.WriteToDb(); } else { anchors = Utils.GetObject(handle) as Autodesk.AdvanceSteel.Modelling.AnchorPattern; if (anchors != null && anchors.IsKindOf(FilerObject.eObjectType.kAnchorPattern)) { SetAnchorSetOutDetails(anchors, astPoint1 + (astPoint2 - astPoint1) * 0.5, Autodesk.AdvanceSteel.Arrangement.Arranger.eArrangerType.kBounded); double aLengthX = Utils.GetRectangleLength(astPoint1, astPoint2, vx); double aLengthY = Utils.GetRectangleLength(astPoint1, astPoint2, vy); anchors.SetArrangerLength(aLengthX, 0); anchors.SetArrangerLength(aLengthY, 1); Utils.SetParameters(anchors, anchorBoltData); } else { throw new System.Exception("Not an anchor pattern"); } } FilerObject[] filerObjects = Utils.GetFilerObjects(handlesToConnect); anchors.Connect(filerObjects, (AtomicElement.eAssemblyLocation)boltCon); Handle = anchors.Handle; SteelServices.ElementBinder.CleanupAndSetElementForTrace(anchors); } } }
static public Autodesk.DesignScript.Geometry.Vector ToDynVector(Autodesk.AdvanceSteel.Geometry.Vector3d vect, bool bConvertFromAstUnits) { double factor = 1.0; if (bConvertFromAstUnits) { var units = AppResolver.Instance.Resolve <IAppInteraction>().DbUnits; factor = units.UnitOfDistance.Factor; } vect = vect * (1 / factor); return(Autodesk.DesignScript.Geometry.Vector.ByCoordinates(vect.x, vect.y, vect.z)); }
internal RectangularBoltPattern(SteelGeometry.Point3d astPoint1, SteelGeometry.Point3d astPoint2, IEnumerable <string> handlesToConnect, SteelGeometry.Vector3d vx, SteelGeometry.Vector3d vy, List <Property> boltData, int boltCon) { lock (access_obj) { using (var ctx = new SteelServices.DocContext()) { Autodesk.AdvanceSteel.Modelling.FinitRectScrewBoltPattern bolts = null; string handle = SteelServices.ElementBinder.GetHandleFromTrace(); if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null) { bolts = new Autodesk.AdvanceSteel.Modelling.FinitRectScrewBoltPattern(astPoint1, astPoint2, vx, vy); bolts.RefPoint = astPoint1 + (astPoint2 - astPoint1) * 0.5; bolts.Length = Utils.GetRectangleLength(astPoint1, astPoint2, vx); bolts.Height = Utils.GetRectangleHeight(astPoint1, astPoint2, vy); Utils.SetParameters(bolts, boltData); bolts.WriteToDb(); } else { bolts = Utils.GetObject(handle) as Autodesk.AdvanceSteel.Modelling.FinitRectScrewBoltPattern; if (bolts != null && bolts.IsKindOf(FilerObject.eObjectType.kFinitRectScrewBoltPattern)) { bolts.XDirection = vx; bolts.YDirection = vy; bolts.RefPoint = astPoint1 + (astPoint2 - astPoint1) * 0.5; bolts.Length = Utils.GetRectangleLength(astPoint1, astPoint2, vx); bolts.Height = Utils.GetRectangleHeight(astPoint1, astPoint2, vy); Utils.SetParameters(bolts, boltData); } else { throw new System.Exception("Not a rectangular pattern"); } } FilerObject[] filerObjects = Utils.GetSteelObjectsToConnect(handlesToConnect); bolts.Connect(filerObjects, (AtomicElement.eAssemblyLocation)boltCon); Handle = bolts.Handle; SteelServices.ElementBinder.CleanupAndSetElementForTrace(bolts); } } }
/// <summary> /// Get Bar Grating Top Normal Vector /// </summary> /// <param name="steelObject">Advance Steel element</param> /// <returns name="gratingNormal"> normal direction as a vector on the top side of the grating</returns> public static Autodesk.DesignScript.Geometry.Vector GetTopNormal(AdvanceSteel.Nodes.SteelDbObject steelObject) { Autodesk.DesignScript.Geometry.Vector ret; //lock the document and start transaction using (var ctx = new SteelServices.DocContext()) { string handle = steelObject.Handle; FilerObject obj = Utils.GetObject(handle); if (obj != null && obj.IsKindOf(FilerObject.eObjectType.kGrating)) { Autodesk.AdvanceSteel.Modelling.Grating grating = obj as Autodesk.AdvanceSteel.Modelling.Grating; Autodesk.AdvanceSteel.Geometry.Vector3d vec = grating.GetTopNormal(); ret = Utils.ToDynVector(vec, true); } else { throw new System.Exception("Not a Grating Object"); } } return(ret); }
internal RectangularShearStudsPattern(SteelGeometry.Point3d astPoint1, SteelGeometry.Point3d astPoint2, string handleToConnect, SteelGeometry.Vector3d vx, SteelGeometry.Vector3d vy, SteelGeometry.Matrix3d coordSyst, List <Property> shearStudData, int boltCon) { lock (access_obj) { List <Property> defaultShearStudData = shearStudData.Where(x => x.Level == ".").ToList <Property>(); List <Property> arrangerShearStudData = shearStudData.Where(x => x.Level == "Arranger").ToList <Property>(); List <Property> postWriteDBData = shearStudData.Where(x => x.Level == "Z_PostWriteDB").ToList <Property>(); int temp_nx = (int)arrangerShearStudData.FirstOrDefault <Property>(x => x.Name == "Nx").InternalValue; int temp_ny = (int)arrangerShearStudData.FirstOrDefault <Property>(x => x.Name == "Ny").InternalValue; var dx = Utils.GetRectangleLength(astPoint1, astPoint2, vx) / (temp_nx - 1); Utils.CheckListUpdateOrAddValue(arrangerShearStudData, "Dx", dx, "Arranger"); var dy = Utils.GetRectangleHeight(astPoint1, astPoint2, vx) / (temp_ny - 1); Utils.CheckListUpdateOrAddValue(arrangerShearStudData, "Dy", dy, "Arranger"); using (var ctx = new SteelServices.DocContext()) { Autodesk.AdvanceSteel.Modelling.Connector shearStuds = null; string handle = SteelServices.ElementBinder.GetHandleFromTrace(); if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null) { shearStuds = new Autodesk.AdvanceSteel.Modelling.Connector(); Autodesk.AdvanceSteel.Arrangement.Arranger arranger = new Autodesk.AdvanceSteel.Arrangement.RectangularArranger(Matrix2d.kIdentity, dx, dy, temp_nx, temp_ny); shearStuds.Arranger = arranger; if (defaultShearStudData != null) { Utils.SetParameters(shearStuds, defaultShearStudData); } Utils.SetParameters(shearStuds.Arranger, arrangerShearStudData); shearStuds.WriteToDb(); if (postWriteDBData != null) { Utils.SetParameters(shearStuds, postWriteDBData); } } else { shearStuds = Utils.GetObject(handle) as Autodesk.AdvanceSteel.Modelling.Connector; if (shearStuds != null || shearStuds.IsKindOf(FilerObject.eObjectType.kConnector)) { if (defaultShearStudData != null) { Utils.SetParameters(shearStuds, defaultShearStudData); } Utils.SetParameters(shearStuds.Arranger, arrangerShearStudData); if (postWriteDBData != null) { Utils.SetParameters(shearStuds, postWriteDBData); } } else { throw new System.Exception("Not a shear stud pattern"); } } FilerObject obj = Utils.GetObject(handleToConnect); Autodesk.AdvanceSteel.Modelling.WeldPoint weld = shearStuds.Connect(obj, coordSyst); weld.AssemblyLocation = (AtomicElement.eAssemblyLocation)boltCon; Handle = shearStuds.Handle; SteelServices.ElementBinder.CleanupAndSetElementForTrace(shearStuds); } } }
internal static void SetOrientation(Autodesk.AdvanceSteel.Modelling.Beam beam, Autodesk.AdvanceSteel.Geometry.Vector3d vOrientation) { beam.PhysCSStart.GetCoordSystem(out _, out Vector3d vXAxis, out Vector3d vYAxis, out Vector3d vZAxis); if (!vXAxis.IsParallelTo(vOrientation)) { Vector3d vProj = vOrientation.OrthoProject(vXAxis); double dAngle = vZAxis.GetAngleTo(vProj, vXAxis); beam.SetXRotation(dAngle * 180 / Math.PI); } }
internal PlatePolycut(AdvanceSteel.Nodes.SteelDbObject element, Polyline3d cutPolyline, Autodesk.AdvanceSteel.Geometry.Vector3d normal, Autodesk.AdvanceSteel.Geometry.Vector3d lengthVector, List <Property> plateFeatureProperties) { lock (access_obj) { using (var ctx = new SteelServices.DocContext()) { List <Property> defaultData = plateFeatureProperties.Where(x => x.Level == ".").ToList <Property>(); List <Property> postWriteDBData = plateFeatureProperties.Where(x => x.Level == "Z_PostWriteDB").ToList <Property>(); string existingFeatureHandle = SteelServices.ElementBinder.GetHandleFromTrace(); string elementHandle = element.Handle; FilerObject obj = Utils.GetObject(elementHandle); PlateContourNotch plateFeat = null; if (obj != null && obj.IsKindOf(FilerObject.eObjectType.kPlate)) { if (string.IsNullOrEmpty(existingFeatureHandle) || Utils.GetObject(existingFeatureHandle) == null) { Plate plate = obj as Plate; plateFeat = new PlateContourNotch(plate, 0, cutPolyline, normal, lengthVector); if (defaultData != null) { Utils.SetParameters(plateFeat, defaultData); } plate.AddFeature(plateFeat); if (postWriteDBData != null) { Utils.SetParameters(plateFeat, postWriteDBData); } } else { plateFeat = Utils.GetObject(existingFeatureHandle) as PlateContourNotch; if (plateFeat != null && plateFeat.IsKindOf(FilerObject.eObjectType.kPlateContourNotch)) { Plate plate = obj as Plate; plate.DelFeature(plateFeat); plate.WriteToDb(); plateFeat = new PlateContourNotch(plate, 0, cutPolyline, normal, lengthVector); AtomicElement atomic = obj as AtomicElement; if (defaultData != null) { Utils.SetParameters(plateFeat, defaultData); } atomic.AddFeature(plateFeat); if (postWriteDBData != null) { Utils.SetParameters(plateFeat, postWriteDBData); } } else { throw new System.Exception("Not a Plate Feature"); } } } else { throw new System.Exception("No Input Element found"); } Handle = plateFeat.Handle; SteelServices.ElementBinder.CleanupAndSetElementForTrace(plateFeat); } } }
internal BeamPolycut(AdvanceSteel.Nodes.SteelDbObject element, int cutShapeRectCircle, Autodesk.AdvanceSteel.Geometry.Point3d insertPoint, Autodesk.AdvanceSteel.Geometry.Vector3d normal, Autodesk.AdvanceSteel.Geometry.Vector3d lengthVector, int corner, List <Property> beamFeatureProperties) { lock (access_obj) { using (var ctx = new SteelServices.DocContext()) { List <Property> defaultData = beamFeatureProperties.Where(x => x.Level == ".").ToList <Property>(); List <Property> postWriteDBData = beamFeatureProperties.Where(x => x.Level == "Z_PostWriteDB").ToList <Property>(); double length = 0; double width = 0; double radius = 0; if (defaultData.FirstOrDefault <Property>(x => x.Name == "Length") != null) { length = (double)defaultData.FirstOrDefault <Property>(x => x.Name == "Length").InternalValue; } if (defaultData.FirstOrDefault <Property>(x => x.Name == "Width") != null) { width = (double)defaultData.FirstOrDefault <Property>(x => x.Name == "Width").InternalValue; } if (defaultData.FirstOrDefault <Property>(x => x.Name == "Radius") != null) { radius = (double)defaultData.FirstOrDefault <Property>(x => x.Name == "Radius").InternalValue; } string existingFeatureHandle = SteelServices.ElementBinder.GetHandleFromTrace(); string elementHandle = element.Handle; FilerObject obj = Utils.GetObject(elementHandle); BeamMultiContourNotch beamFeat = null; if (obj != null && obj.IsKindOf(FilerObject.eObjectType.kBeam)) { if (string.IsNullOrEmpty(existingFeatureHandle) || Utils.GetObject(existingFeatureHandle) == null) { Beam bmObj = obj as Beam; switch (cutShapeRectCircle) { case 0: beamFeat = new BeamMultiContourNotch(bmObj, (Beam.eEnd) 1, insertPoint, normal, lengthVector, length, width); break; case 1: beamFeat = new BeamMultiContourNotch(bmObj, (Beam.eEnd) 1, insertPoint, normal, lengthVector, radius); break; } Vector2d offset; switch (corner) { case 0: //Top Left offset = new Vector2d(-1, 1); break; case 1: //Top Right offset = new Vector2d(1, 1); break; case 2: //Bottom Right offset = new Vector2d(1, -1); break; case 3: //Bottom left offset = new Vector2d(-1, -1); break; default: //Anything else ignore offset = new Vector2d(0, 0); break; } beamFeat.Offset = offset; if (defaultData != null) { Utils.SetParameters(beamFeat, defaultData); } bmObj.AddFeature(beamFeat); if (postWriteDBData != null) { Utils.SetParameters(beamFeat, postWriteDBData); } } else { beamFeat = Utils.GetObject(existingFeatureHandle) as BeamMultiContourNotch; if (beamFeat != null && beamFeat.IsKindOf(FilerObject.eObjectType.kBeamMultiContourNotch)) { beamFeat.End = (Beam.eEnd) 0; Matrix3d cutMatrix = beamFeat.CS; Point3d orgin = null; Vector3d xVec = null; Vector3d yVec = null; Vector3d zVec = null; cutMatrix.GetCoordSystem(out orgin, out xVec, out yVec, out zVec); xVec = new Vector3d(lengthVector); yVec = xVec.CrossProduct(normal); zVec = xVec.CrossProduct(yVec); cutMatrix.SetCoordSystem(insertPoint, xVec, yVec, zVec); beamFeat.CS = cutMatrix; Vector2d offset; switch (corner) { case 0: //Top Left offset = new Vector2d(-1, 1); break; case 1: //Top Right offset = new Vector2d(1, 1); break; case 2: //Bottom Right offset = new Vector2d(1, -1); break; case 3: //Bottom left offset = new Vector2d(-1, -1); break; default: //Anything else ignore offset = new Vector2d(0, 0); break; } beamFeat.Offset = offset; if (defaultData != null) { Utils.SetParameters(beamFeat, defaultData); } if (postWriteDBData != null) { Utils.SetParameters(beamFeat, postWriteDBData); } } else { throw new System.Exception("Not a Beam Feature"); } } } else { throw new System.Exception("No Input Element found"); } Handle = beamFeat.Handle; SteelServices.ElementBinder.CleanupAndSetElementForTrace(beamFeat); } } }
internal BeamPolycut(AdvanceSteel.Nodes.SteelDbObject element, Polyline3d cutPolyline, Autodesk.AdvanceSteel.Geometry.Vector3d normal, Autodesk.AdvanceSteel.Geometry.Vector3d lengthVector, List <Property> beamFeatureProperties) { lock (access_obj) { using (var ctx = new SteelServices.DocContext()) { List <Property> defaultData = beamFeatureProperties.Where(x => x.Level == ".").ToList <Property>(); List <Property> postWriteDBData = beamFeatureProperties.Where(x => x.Level == "Z_PostWriteDB").ToList <Property>(); string existingFeatureHandle = SteelServices.ElementBinder.GetHandleFromTrace(); string elementHandle = element.Handle; FilerObject obj = Utils.GetObject(elementHandle); BeamMultiContourNotch beamFeat = null; if (obj != null && obj.IsKindOf(FilerObject.eObjectType.kBeam)) { if (string.IsNullOrEmpty(existingFeatureHandle) || Utils.GetObject(existingFeatureHandle) == null) { Beam bmObj = obj as Beam; beamFeat = new BeamMultiContourNotch(bmObj, (Beam.eEnd) 1, cutPolyline, normal, lengthVector); if (defaultData != null) { Utils.SetParameters(beamFeat, defaultData); } bmObj.AddFeature(beamFeat); if (postWriteDBData != null) { Utils.SetParameters(beamFeat, postWriteDBData); } } else { beamFeat = Utils.GetObject(existingFeatureHandle) as BeamMultiContourNotch; if (beamFeat != null && beamFeat.IsKindOf(FilerObject.eObjectType.kBeamMultiContourNotch)) { Beam bmObj = obj as Beam; bmObj.DelFeature(beamFeat); bmObj.WriteToDb(); beamFeat = new BeamMultiContourNotch(bmObj, (Beam.eEnd) 1, cutPolyline, normal, lengthVector); if (defaultData != null) { Utils.SetParameters(beamFeat, defaultData); } bmObj.AddFeature(beamFeat); if (postWriteDBData != null) { Utils.SetParameters(beamFeat, postWriteDBData); } } else { throw new System.Exception("Not a Beam Feature"); } } } else { throw new System.Exception("No Input Element found"); } Handle = beamFeat.Handle; SteelServices.ElementBinder.CleanupAndSetElementForTrace(beamFeat); } } }
internal Walls(SteelGeometry.Matrix3d matrix, double dLength, double dHeight, double thickness, List <Property> concreteProperties) { lock (access_obj) { using (var ctx = new SteelServices.DocContext()) { List <Property> defaultData = concreteProperties.Where(x => x.Level == ".").ToList <Property>(); List <Property> postWriteDBData = concreteProperties.Where(x => x.Level == "Z_PostWriteDB").ToList <Property>(); SteelGeometry.Point3d baseOrigin = new SteelGeometry.Point3d(); SteelGeometry.Vector3d xAxis = new SteelGeometry.Vector3d(); SteelGeometry.Vector3d yAxis = new SteelGeometry.Vector3d(); SteelGeometry.Vector3d zAxis = new SteelGeometry.Vector3d(); matrix.GetCoordSystem(out baseOrigin, out xAxis, out yAxis, out zAxis); SteelGeometry.Vector3d lengthVec = xAxis * dLength; SteelGeometry.Vector3d heightVec = zAxis * dHeight; SteelGeometry.Point3d brPnt = new SteelGeometry.Point3d(baseOrigin).Add(lengthVec); SteelGeometry.Point3d trPnt = new SteelGeometry.Point3d(brPnt).Add(heightVec); SteelGeometry.Point3d tlPnt = new SteelGeometry.Point3d(baseOrigin).Add(heightVec); SteelGeometry.Point3d centerWallPnt = baseOrigin.GetMidPointBetween(trPnt); SteelGeometry.Point3d[] wallPoints = { baseOrigin, brPnt, trPnt, tlPnt }; double[] cornerRadii = (double[])System.Collections.ArrayList.Repeat(0.0, wallPoints.Length).ToArray(typeof(double)); SteelGeometry.Plane plane = new SteelGeometry.Plane(centerWallPnt, yAxis); Autodesk.AdvanceSteel.Modelling.Wall wallObject = null; string handle = SteelServices.ElementBinder.GetHandleFromTrace(); if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null) { wallObject = new Autodesk.AdvanceSteel.Modelling.Wall(plane, wallPoints); wallObject.Thickness = thickness; Polyline3d outerPoly = new Polyline3d(wallPoints, cornerRadii, true, yAxis, false, 0, true, true); IEnumerable <ObjectId> deletedFeaturesIds = null; IEnumerable <ObjectId> newFeaturesIds = null; wallObject.SetOuterContour(outerPoly, out deletedFeaturesIds, out newFeaturesIds); if (defaultData != null) { Utils.SetParameters(wallObject, defaultData); } wallObject.WriteToDb(); if (postWriteDBData != null) { Utils.SetParameters(wallObject, postWriteDBData); } } else { wallObject = Utils.GetObject(handle) as Autodesk.AdvanceSteel.Modelling.Wall; if (wallObject != null && wallObject.IsKindOf(FilerObject.eObjectType.kWall)) { //TODO - Missing SetPolygon wallObject.DefinitionPlane = plane; wallObject.Thickness = thickness; Polyline3d outerPoly = new Polyline3d(wallPoints, cornerRadii, true, yAxis, false, 0, true, true); IEnumerable <ObjectId> deletedFeaturesIds = null; IEnumerable <ObjectId> newFeaturesIds = null; if (defaultData != null) { Utils.SetParameters(wallObject, defaultData); } wallObject.SetOuterContour(outerPoly, out deletedFeaturesIds, out newFeaturesIds); if (postWriteDBData != null) { Utils.SetParameters(wallObject, postWriteDBData); } } else { throw new System.Exception("Not a Wall"); } } Handle = wallObject.Handle; SteelServices.ElementBinder.CleanupAndSetElementForTrace(wallObject); } } }
internal Walls(SteelGeometry.Point3d ptCenter, double dLength, double dHeight, double thickness, SteelGeometry.Vector3d vNormal, List <Property> concreteProperties) { lock (access_obj) { using (var ctx = new SteelServices.DocContext()) { List <Property> defaultData = concreteProperties.Where(x => x.Level == ".").ToList <Property>(); List <Property> postWriteDBData = concreteProperties.Where(x => x.Level == "Z_PostWriteDB").ToList <Property>(); SteelGeometry.Plane plane = new SteelGeometry.Plane(ptCenter, vNormal); Autodesk.AdvanceSteel.Modelling.Wall wallObject = null; string handle = SteelServices.ElementBinder.GetHandleFromTrace(); if (string.IsNullOrEmpty(handle) || Utils.GetObject(handle) == null) { wallObject = new Autodesk.AdvanceSteel.Modelling.Wall(plane, ptCenter, dLength, dHeight); wallObject.Thickness = thickness; if (defaultData != null) { Utils.SetParameters(wallObject, defaultData); } wallObject.WriteToDb(); if (postWriteDBData != null) { Utils.SetParameters(wallObject, postWriteDBData); } } else { wallObject = Utils.GetObject(handle) as Autodesk.AdvanceSteel.Modelling.Wall; if (wallObject != null && wallObject.IsKindOf(FilerObject.eObjectType.kWall)) { wallObject.DefinitionPlane = plane; wallObject.Thickness = thickness; wallObject.SetLength(dLength, true); wallObject.SetWidth(dHeight, true); if (defaultData != null) { Utils.SetParameters(wallObject, defaultData); } if (postWriteDBData != null) { Utils.SetParameters(wallObject, postWriteDBData); } } else { throw new System.Exception("Not a Wall"); } } Handle = wallObject.Handle; SteelServices.ElementBinder.CleanupAndSetElementForTrace(wallObject); } } }