public TsPart(TSD.Part drawingPart) { _drawingPart = drawingPart; TSM.Part modelPart = Extensions.GetModelObjectFromDrawingObject(_drawingPart) as TSM.Part; modelPart.GetReportProperty("WIDTH", ref width); modelPart.GetReportProperty("HEIGHT", ref height); modelPart.GetReportProperty("LENGTH", ref length); var partCLPoints = modelPart.GetCenterLine(false); Point partStartP = partCLPoints[0] as Point; Point partEndP; if (!(modelPart is TSM.ContourPlate)) { partEndP = partCLPoints[partCLPoints.Count - 1] as Point; } else { partEndP = partCLPoints[partCLPoints.Count - 2] as Point; } partStart = new double[3] { partStartP.X, partStartP.Y, partStartP.Z }; partEnd = new double[3] { partEndP.X, partEndP.Y, partEndP.Z }; partCS = modelPart.GetCoordinateSystem(); origin = new Point((partEnd[0] + partStart[0]) / 2, (partEnd[1] + partStart[1]) / 2, (partEnd[2] + partStart[2]) / 2); }
public static double GetPartWidth(TSM.Part part) { double columnWidth = 0.0; if (!part.GetReportProperty("PROFILE.WIDTH", ref columnWidth)) { part.GetReportProperty("WIDTH", ref columnWidth); } return(columnWidth); }
/// <summary> /// HeghlightElements(List<Elm>elements, color) - change color of elements in list /// </summary> /// <param name="elements"></param> /// <param name="color"></param> public void HighlightElements(Dictionary<string, Elm> els, int color = 1) { Log.set("TS_OpenAPI.HighLightElements"); TSM.ModelObjectSelector selector = model.GetModelObjectSelector(); System.Type[] Types = new System.Type[1]; Types.SetValue(typeof(Part), 0); TSM.ModelObjectEnumerator objectList = selector.GetAllObjectsWithType(Types); int totalCnt = objectList.GetSize(); var colorObjects = new List<ModelObject>(); while (objectList.MoveNext()) { TSM.Part myPart = objectList.Current as TSM.Part; if (myPart != null) { string guid = string.Empty; myPart.GetReportProperty("GUID", ref guid); if (els.ContainsKey(guid)) colorObjects.Add(myPart); } } var _color = new Color(0.0, 0.0, 1.0); ModelObjectVisualization.SetTransparencyForAll(TemporaryTransparency.SEMITRANSPARENT); ModelObjectVisualization.SetTemporaryState(colorObjects, _color); log.Info("\tTotal elements without price = " + colorObjects.Count); Log.exit(); }
public static void Run(Tekla.Technology.Akit.IScript akit) { try { Model model = new Model(); TransformationPlane transformationplane = model.GetWorkPlaneHandler().GetCurrentTransformationPlane(); model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane()); ModelObjectEnumerator modelObjectEnum = model.GetModelObjectSelector().GetSelectedObjects(); if (modelObjectEnum.GetSize() == 1) { while (modelObjectEnum.MoveNext()) { if (modelObjectEnum.Current is Tekla.Structures.Model.Part) { Tekla.Structures.Model.Part part = modelObjectEnum.Current as Tekla.Structures.Model.Part; double level = 0; part.GetReportProperty("TOP_LEVEL_UNFORMATTED", ref level); akit.CommandStart("ail_create_basic_view", "", "main_frame"); akit.ValueChange("Modelling create view", "v1_coordinate", level.ToString("F02")); akit.PushButton("v1_create", "Modelling create view"); } } } model.GetWorkPlaneHandler().SetCurrentTransformationPlane(transformationplane); } catch { } }
internal static string GetPartProfileType(TSD.Part drawingPart) { TSM.Part modelPart = SelectModelObject(drawingPart.ModelIdentifier.ID) as TSM.Part; string profileType = String.Empty; modelPart.GetReportProperty("PROFILE_TYPE", ref profileType); return(profileType); }
public static double GetPartHeight(TSM.Part part) { double columnHeight = 0.0; string profile = string.Empty; part.GetReportProperty("PROFILE", ref profile); string[] split = profile.Split('X'); columnHeight = double.Parse(split[1]); return(columnHeight); }
private void GetMarks(string MarkType) { Model model = new Model(); Tekla.Structures.Model.UI.ModelObjectSelector modelObjectSelector = new Tekla.Structures.Model.UI.ModelObjectSelector(); Drawing drawing = drawingHandler.GetActiveDrawing(); DrawingObjectEnumerator drawingObjectEnumerator = drawingHandler.GetDrawingObjectSelector().GetSelected(); ArrayList SelectedObjectArray = new ArrayList(); ArrayList MarkArray = new ArrayList(); while (drawingObjectEnumerator.MoveNext()) { if (drawingObjectEnumerator.Current is Tekla.Structures.Drawing.Part) { Tekla.Structures.Drawing.Part part = drawingObjectEnumerator.Current as Tekla.Structures.Drawing.Part; SelectedObjectArray.Add(model.SelectModelObject(new Identifier(part.ModelIdentifier.ID))); DrawingObjectArray.Add(part); } } modelObjectSelector.Select(SelectedObjectArray); Tekla.Structures.Model.ModelObjectEnumerator modelObjectEnumerator = model.GetModelObjectSelector().GetSelectedObjects(); while (modelObjectEnumerator.MoveNext()) { if (modelObjectEnumerator.Current is Tekla.Structures.Model.Part) { Tekla.Structures.Model.Part modelPart = modelObjectEnumerator.Current as Tekla.Structures.Model.Part; string mark = ""; try { modelPart.GetReportProperty(MarkType, ref mark); if (!MarkArray.Contains(mark)) { MarkArray.Add(mark); } } catch { } } } MarkArray.Sort(); string MarkList = ""; foreach (string strMark in MarkArray) { MarkList = strMark + " " + MarkList; } Clipboard.SetDataObject(MarkList); richTextBox1.Text = MarkList; drawingHandler.GetDrawingObjectSelector().SelectObjects(DrawingObjectArray, false); }
public static double GetGirderHeight(TSM.Part girder) { double girderHeight = 0; if (girder is TSM.Beam) { girderHeight = GetPartHeight(girder); } else if (girder is TSM.ContourPlate) { string profile = string.Empty; girder.GetReportProperty("PROFILE", ref profile); string[] split = profile.Split('X'); girderHeight = double.Parse(split[1]); } return(girderHeight); }
static void Main(string[] args) { var picker = new TSM.UI.Picker(); var result = picker.PickObject(TSM.UI.Picker.PickObjectEnum.PICK_ONE_PART); TSM.Part part = result as TSM.Part; string profileType = null; part.GetReportProperty("PROFILE_TYPE", ref profileType); string dstv = string.Empty; bool success = TSM.Operations.Operation.CreateNCFilesByPartId("DSTV - Shafts", "", part.Identifier, out dstv); string[] dstvLines = dstv.Split(new string[] { "\n" }, StringSplitOptions.None); string dstvCode = dstvLines[9].Trim(); Console.WriteLine($"PROFILE_TYPE: {profileType}"); Console.WriteLine($"DSTV CODE: {dstvCode}"); Console.ReadKey(); }
/// <summary> /// 获取图纸中的视图信息; /// </summary> private void GetDrawingViewInfo() { DrawingObjectEnumerator allViews = mAssemblyDrawing.GetSheet().GetAllViews(); while (allViews.MoveNext()) { if (allViews.Current == null) { continue; } TSD.View view = allViews.Current as TSD.View; if (view == null) { continue; } view.Select(); //创建自定义的主梁对象; CMrMainBeam mainBeam = new CMrMainBeam(mMainPart, null); CMrMainBeam.SetInstance(mainBeam); double dblFlangeThickness = 0.0; double dblWebThickness = 0.0; mMainPart.GetReportProperty("PROFILE.FLANGE_THICKNESS", ref dblFlangeThickness); mMainPart.GetReportProperty("PROFILE.WEB_THICKNESS", ref dblWebThickness); mainBeam.mFlangeThickness = dblFlangeThickness; mainBeam.mWebThickness = dblWebThickness; int size = view.GetObjects(new Type[] { typeof(TSD.Part) }).GetSize(); if (size == 0 || size == 1) { continue; } Vector xVector = new Vector(1, 0, 0); Vector yVector = new Vector(0, 1, 0); Vector zVector = new Vector(0, 0, 1); CDimTools.GetInstance().InitMrPart(mMainPart, view, mainBeam); Vector vector = mainBeam.mNormal; double minY = mainBeam.GetMinYPoint().Y; double maxY = mainBeam.GetMaxYPoint().Y; double mainBeamHeight = Math.Abs(maxY - minY); //顶视图标注; if (CDimTools.GetInstance().IsTwoVectorParallel(vector, xVector)) { Point viewMinPoint = view.RestrictionBox.MinPoint; Point viewMaxPoint = view.RestrictionBox.MaxPoint; double viewHeight = Math.Abs(viewMaxPoint.Y - viewMinPoint.Y); if (CDimTools.GetInstance().CompareTwoDoubleValue(viewHeight, mainBeamHeight) >= 0) { continue; } else { mAllSectionViewList.Add(view); } } //前视图标注; else if (CDimTools.GetInstance().IsTwoVectorParallel(vector, zVector)) { Point viewMinPoint = view.RestrictionBox.MinPoint; Point viewMaxPoint = view.RestrictionBox.MaxPoint; double viewHeight = Math.Abs(viewMaxPoint.Y - viewMinPoint.Y); if (CDimTools.GetInstance().CompareTwoDoubleValue(viewHeight, mainBeamHeight) >= 0) { mFrontView = view; } else { mAllSectionViewList.Add(view); } } //剖视图标注; else { mAllSectionViewList.Add(view); } } }
public Tekla() { } // конструктор класса Tekla - пока пустой 6.4.17 public List<Elm> Read(string dir = "", string name = "") { Log.set("TS_OpenAPI.Read"); List<Elm> elements = new List<Elm>(); // 6.4.17 //TSM.Model model = new TSM.Model(); ////////////List<Part> parts = new List<Part>(); ModInfo = model.GetInfo(); if (dir != "" && ModInfo.ModelPath != dir || name != "" && ModInfo.ModelName != String.Concat(name, ".db1")) Msg.F("Tekla.Read: Another model loaded, not", name); ModInfo.ModelName = ModInfo.ModelName.Replace(".db1", ""); TSM.ModelObjectSelector selector = model.GetModelObjectSelector(); System.Type[] Types = new System.Type[1]; Types.SetValue(typeof(Part), 0); TSM.ModelObjectEnumerator objectList = selector.GetAllObjectsWithType(Types); int totalCnt = objectList.GetSize(); var progress = new TSM.Operations.Operation.ProgressBar(); bool displayResult = progress.Display(100, "TSmatch", "Reading model. Pass component records:", "Cancel", " "); int ii = 0; while (objectList.MoveNext()) { TSM.Part myPart = objectList.Current as TSM.Part; if (myPart != null) { ii++; double lng = 0.0; double weight = 0.0; double vol = 0.0; string guid = ""; string mat_type = ""; double price = 0.0; myPart.GetReportProperty("GUID", ref guid); myPart.GetReportProperty("LENGTH", ref lng); myPart.GetReportProperty("WEIGHT", ref weight); myPart.GetReportProperty("VOLUME", ref vol); myPart.GetReportProperty("MATERIAL_TYPE", ref mat_type); lng = Math.Round(lng, 0); //string cut = ""; //myPart.GetReportProperty("CAST_UNIT_TYPE", ref cut); //ModAtr.Add(new AttSet(myPart.Material.MaterialString, // profile, lng, weight, vol)); //21/6/2016 в отладке Elm.Elements.Add(new Elm()); elements.Add(new Elm(guid, myPart.Material.MaterialString, mat_type, myPart.Profile.ProfileString, lng, weight, vol, price)); // !! if (ii % 500 == 0) // progress update every 500th items { if (progress.Canceled()) { // new Log("\n\n======= TSmatch pass model CANCEL!! ======= ii=" + ii); // TSD.Show() break; } progress.SetProgress(ii.ToString(), 100 * ii / totalCnt); } } } //while progress.Close(); Scale(elements); elements.Sort(); Log.exit(); return elements; } // Read
/// <summary> /// 根据视图绘制门式框架结构的图纸; /// </summary> /// <param name="view"></param> /// <param name="mainPart"></param> /// <param name="strDimType"></param> private void DrawDrawingDoorByView(TSD.View view, TSM.Part mainPart, string strDimType) { view.Select(); //创建自定义的主梁对象; CMrMainBeam mainBeam = new CMrMainBeam(mainPart, null); CMrMainBeam.SetInstance(mainBeam); double dblFlangeThickness = 0.0; double dblWebThickness = 0.0; mainPart.GetReportProperty("PROFILE.FLANGE_THICKNESS", ref dblFlangeThickness); mainPart.GetReportProperty("PROFILE.WEB_THICKNESS", ref dblWebThickness); mainBeam.mFlangeThickness = dblFlangeThickness; mainBeam.mWebThickness = dblWebThickness; int size = view.GetObjects(new Type[] { typeof(TSD.Part) }).GetSize(); //如果零部件个数为0或1分别表示空视图和零件图则不进行标注; if (size == 0 || size == 1) { return; } Vector xVector = new Vector(1, 0, 0); Vector yVector = new Vector(0, 1, 0); Vector zVector = new Vector(0, 0, 1); CDimTools.GetInstance().InitMrPart(mainPart, view, mainBeam); Vector vector = mainBeam.mNormal; double minY = mainBeam.GetMinYPoint().Y; double maxY = mainBeam.GetMaxYPoint().Y; double minX = mainBeam.GetMinXPoint().X; double maxX = mainBeam.GetMaxXPoint().X; double mainBeamHeight = Math.Abs(maxY - minY); double mainBeamWidth = Math.Abs(maxX - minX); if (strDimType == "梁标注") { Point viewMinPoint = view.RestrictionBox.MinPoint; Point viewMaxPoint = view.RestrictionBox.MaxPoint; double viewWidth = Math.Abs(viewMaxPoint.X - viewMinPoint.X); //顶视图不需要进行标注; if (CDimTools.GetInstance().IsTwoVectorParallel(vector, yVector) && CDimTools.GetInstance().CompareTwoDoubleValue(viewWidth, mainBeamWidth) >= 0) { } //主视图标注; else if (CDimTools.GetInstance().IsTwoVectorParallel(vector, zVector) && CDimTools.GetInstance().CompareTwoDoubleValue(viewWidth, mainBeamWidth) >= 0) { CBeamDoorFrontView mFrontView = new CBeamDoorFrontView(view, mModel); InitView(view); mFrontView.CreateDim(); } //剖视图标注; else { CBeamDoorSectionView mSectionView = new CBeamDoorSectionView(view, mModel); InitView(view); mSectionView.CreateDim(); } } else if (strDimType == "柱标注") { Point viewMinPoint = view.RestrictionBox.MinPoint; Point viewMaxPoint = view.RestrictionBox.MaxPoint; double viewHeight = Math.Abs(viewMaxPoint.Y - viewMinPoint.Y); //顶视图标注; if (CDimTools.GetInstance().IsTwoVectorParallel(vector, xVector) && CDimTools.GetInstance().CompareTwoDoubleValue(viewHeight, mainBeamHeight) >= 0) { CCylinderDoorTopView mTopView = new CCylinderDoorTopView(view, mModel); InitView(view); mTopView.CreateDim(); } //主视图标注; else if (CDimTools.GetInstance().IsTwoVectorParallel(vector, zVector) && CDimTools.GetInstance().CompareTwoDoubleValue(viewHeight, mainBeamHeight) >= 0) { CCylinderDoorFrontView mFrontView = new CCylinderDoorFrontView(view, mModel); InitView(view); mFrontView.CreateDim(); } //剖视图标注; else { CCylinderDoorSectionView mSectionView = new CCylinderDoorSectionView(view, mModel); InitView(view); mSectionView.CreateDim(); } } }
private void btnConvert_Click(object sender, EventArgs e) { ModelObjectSelector mos = new ModelObjectSelector(); TSM.ModelObjectEnumerator moe = mos.GetSelectedObjects(); moe.SelectInstances = false; while (moe.MoveNext()) { if (moe.Current is TSM.Part) { TSM.Part part = moe.Current as TSM.Part; // this method needs to be called to properly fill all the properties of the part part.Select(); double partLength = 0.0; double partHeight = 0.0; double partWidth = 0.0; part.GetReportProperty("LENGTH", ref partLength); part.GetReportProperty("HEIGHT", ref partHeight); part.GetReportProperty("WIDTH", ref partWidth); TSM.ModelObjectEnumerator MyAllBooleans = part.GetBooleans(); TSM.ModelObjectEnumerator MyAllBolts = part.GetBolts(); TSM.ModelObject MyFather = part.GetFatherComponent(); TSG.CoordinateSystem coordinateSystem = part.GetCoordinateSystem(); TSM.WorkPlaneHandler planeHandler = model.GetWorkPlaneHandler(); // before we create a new plane we need to store the old one TSM.TransformationPlane original = planeHandler.GetCurrentTransformationPlane(); TSM.TransformationPlane partPlane = new TSM.TransformationPlane(coordinateSystem); planeHandler.SetCurrentTransformationPlane(partPlane); //this.DrawCoordinateSystem(); TSG.Point p1 = new TSG.Point(0, partHeight / 2, 0); TSG.Point p2 = new TSG.Point(partLength, partHeight / 2, 0); TSG.Point p3 = new TSG.Point(partLength, -partHeight / 2, 0); TSG.Point p4 = new TSG.Point(0, -partHeight / 2, 0); TSM.ContourPlate CP = new TSM.ContourPlate(); TSM.ContourPoint conturePoint1 = new TSM.ContourPoint(p1, null); TSM.ContourPoint conturePoint2 = new TSM.ContourPoint(p2, null); TSM.ContourPoint conturePoint3 = new TSM.ContourPoint(p3, null); TSM.ContourPoint conturePoint4 = new TSM.ContourPoint(p4, null); CP.AddContourPoint(conturePoint1); CP.AddContourPoint(conturePoint2); CP.AddContourPoint(conturePoint3); CP.AddContourPoint(conturePoint4); CP.Name = "NEM"; CP.Finish = "xxx"; CP.Profile.ProfileString = "PL" + partWidth; CP.Material.MaterialString = "S235"; CP.Class = "1"; CP.Insert(); while (MyAllBooleans.MoveNext()) { try { TSM.BooleanPart partBooleans = MyAllBooleans.Current as TSM.BooleanPart; TSM.Part partBool = partBooleans.OperativePart as TSM.Part; partBool.Class = TSM.BooleanPart.BooleanOperativeClassName; partBool.Insert(); TSM.BooleanPart myboolpart = new TSM.BooleanPart(); myboolpart.Father = CP; myboolpart.SetOperativePart(partBool); myboolpart.Insert(); partBool.Delete(); } catch (Exception) { throw; } } while (MyAllBolts.MoveNext()) { try { if (MyAllBolts.Current is TSM.BoltGroup) { TSM.BoltGroup b = MyAllBolts.Current as TSM.BoltGroup; TSM.Part toBolted = b.PartToBeBolted as TSM.Part; TSM.Part toBolt = b.PartToBoltTo as TSM.Part; if (toBolted.Identifier.ID == toBolt.Identifier.ID) { b.PartToBeBolted = CP; b.PartToBoltTo = CP; } else if (toBolted.Identifier.ID == part.Identifier.ID) { b.PartToBoltTo.GetBolts(); b.PartToBeBolted = CP; } else { b.PartToBoltTo = CP; b.PartToBeBolted.GetBolts(); } b.Insert(); } } catch (Exception) { throw; } } if (MyFather != null) { TSM.ModelObjectEnumerator elementOfComponenet = MyFather.GetChildren(); while (elementOfComponenet.MoveNext()) { TSM.Part element = elementOfComponenet.Current as TSM.Part; try { if (element is TSM.Part) { if (element.Identifier.ID == part.Identifier.ID) { element = CP; element.Modify(); } else { continue; } } else { continue; } } catch (Exception) { throw; } } } part.Delete(); planeHandler.SetCurrentTransformationPlane(original); } } this.model.CommitChanges(); }