/// <summary> /// 框架结构的一键标注; /// </summary> /// <param name="nType"></param> public void DrawDrawingOneKey(string strDimType) { DrawingHandler drawingHandler = new DrawingHandler(); Drawing drawing = drawingHandler.GetActiveDrawing(); if (null == drawing) { return; } AssemblyDrawing assemblyDrawing = drawing as AssemblyDrawing; if (assemblyDrawing == null) { return; } // try // { Assembly assembly = new Assembly { Identifier = assemblyDrawing.AssemblyIdentifier }; assembly.Select(); Identifier identifier = assembly.GetMainPart().Identifier; TSM.Part modelObject = mModel.SelectModelObject(identifier) as TSM.Part; //1.首先创建自动剖面; if (CCommonPara.mAutoSectionType == MrAutoSectionType.MrOneKeyDim || CCommonPara.mAutoSectionType == MrAutoSectionType.MrTwoTypeDim) { CreateAutoSection(strDimType, modelObject, assemblyDrawing); } //2.对图纸进行标注; DrawingObjectEnumerator allViews = assemblyDrawing.GetSheet().GetAllViews(); while (allViews.MoveNext()) { if (allViews.Current != null) { TSD.View view = allViews.Current as TSD.View; if (view != null) { DrawDrawingByView(view, modelObject, strDimType); } } } assemblyDrawing.IsFrozen = true; assemblyDrawing.PlaceViews(); assemblyDrawing.Modify(); // } // catch (System.Exception ex) // { // string strName = assemblyDrawing.Name; // MessageBox.Show("图纸" + strName + "标注失败,请确认模型或图纸内是否有问题。异常信息:" + ex.Message); // } MessageBox.Show("扬州Tekla培训石头哥提示您标注结束,感谢您对智能标注系统的支持。"); }
public void Modify(PropertyValueChangedEventArgs e) { string label = e.ChangedItem.Label; Drawing drawing = drawingHandler.GetActiveDrawing(); DrawingObjectEnumerator drawingObjectEnum = drawingHandler.GetDrawingObjectSelector().GetSelected(); while (drawingObjectEnum.MoveNext()) { if (drawingObjectEnum.Current is Tekla.Structures.Drawing.View) { Tekla.Structures.Drawing.View drawingView = (Tekla.Structures.Drawing.View)drawingObjectEnum.Current; if (label == "Scale") { drawingView.Attributes.Scale = double.Parse(scale); } if (label == "SizeXMin") { drawingView.RestrictionBox.MinPoint.X = double.Parse(sizeXMin); } if (label == "SizeXMax") { drawingView.RestrictionBox.MaxPoint.X = double.Parse(sizeXMax); } if (label == "SizeYMin") { drawingView.RestrictionBox.MinPoint.Y = double.Parse(sizeYMin); } if (label == "SizeYMax") { drawingView.RestrictionBox.MaxPoint.Y = double.Parse(sizeYMax); } if (label == "SizeDepthDown") { drawingView.RestrictionBox.MinPoint.Z = double.Parse(sizeDepthDown) * -1; } if (label == "SizeDepthUp") { drawingView.RestrictionBox.MaxPoint.Z = double.Parse(sizeDepthUp); } if (label == "ViewExtension") { drawingView.Attributes.ViewExtensionForNeighbourParts = double.Parse(viewExtension); } if (label == "FixedViewPlacing") { drawingView.Attributes.FixedViewPlacing = bool.Parse(fixedViewPlacing.ToString()); } if (label == "CutParts") { drawingView.Attributes.Shortening.CutParts = bool.Parse(cutParts.ToString()); } if (label == "MinimumLength") { drawingView.Attributes.Shortening.MinimumLength = double.Parse(minimumLength); } drawingView.Modify(); drawing.CommitChanges(); } } }
public static void Run(Tekla.Technology.Akit.IScript akit) { Model model = new Model(); //Tekla.Structures.Model.UI.ModelObjectSelector modelObjectSelector = new Tekla.Structures.Model.UI.ModelObjectSelector(); DrawingHandler dh = new DrawingHandler(); DrawingObjectEnumerator doe = dh.GetDrawingObjectSelector().GetSelected(); while (doe.MoveNext()) { string CONN_CODE_END1 = "", CONN_CODE_END2 = ""; if (doe.Current is Tekla.Structures.Drawing.Part) { Tekla.Structures.Drawing.Part dPart = (Tekla.Structures.Drawing.Part)doe.Current; Tekla.Structures.Model.Part mPart = (Tekla.Structures.Model.Part)model.SelectModelObject((Identifier)dPart.ModelIdentifier); if (mPart is Beam) { Beam beam = (Beam)mPart; ViewBase view = dPart.GetView(); mPart.GetUserProperty("CONN_CODE_END1", ref CONN_CODE_END1); mPart.GetUserProperty("CONN_CODE_END2", ref CONN_CODE_END2); if (CONN_CODE_END1 != "") { Tekla.Structures.Drawing.Text text = new Tekla.Structures.Drawing.Text(view, beam.StartPoint + new Point(200, 200), CONN_CODE_END1, new LeaderLinePlacing(beam.StartPoint)); text.Insert(); } if (CONN_CODE_END2 != "") { Tekla.Structures.Drawing.Text text = new Tekla.Structures.Drawing.Text(view, beam.EndPoint + new Point(200, 200), CONN_CODE_END2, new LeaderLinePlacing(beam.EndPoint)); text.Insert(); } } } } }
public static void Run(Tekla.Technology.Akit.IScript akit) { try { Model model = new Model(); DrawingHandler drawingHandler = new DrawingHandler(); ArrayList ModelObjectArray = new ArrayList(); if (drawingHandler.GetActiveDrawing() != null) { DrawingObjectEnumerator drawingObjectEnum = drawingHandler.GetDrawingObjectSelector().GetSelected(); if (drawingObjectEnum.GetSize() > 0) { while (drawingObjectEnum.MoveNext()) { Tekla.Structures.Drawing.ModelObject dModelObject = (Tekla.Structures.Drawing.ModelObject)drawingObjectEnum.Current; ModelObjectArray.Add(model.SelectModelObject(dModelObject.ModelIdentifier)); } } Tekla.Structures.Model.UI.ModelObjectSelector modelObjectSelector = new Tekla.Structures.Model.UI.ModelObjectSelector(); modelObjectSelector.Select(ModelObjectArray); } akit.Callback("acmdZoomToSelected", "", "main_frame"); } catch { } }
public void Modify(PropertyValueChangedEventArgs e) { string label = e.ChangedItem.Label; Drawing drawing = drawingHandler.GetActiveDrawing(); DrawingObjectEnumerator drawingObjectEnum = drawingHandler.GetDrawingObjectSelector().GetSelected(); while (drawingObjectEnum.MoveNext()) { if (drawingObjectEnum.Current is Tekla.Structures.Drawing.Bolt) { Tekla.Structures.Drawing.Bolt drawingBolt = (Tekla.Structures.Drawing.Bolt)drawingObjectEnum.Current; if (label == "BoltRepresentation") { drawingBolt.Attributes.Representation = boltRepresentation; } if (label == "SymbolContainsAxis") { drawingBolt.Attributes.SymbolContainsAxis = bool.Parse(symbolContainsAxis.ToString()); } if (label == "SymbolContainsHole") { drawingBolt.Attributes.SymbolContainsHole = bool.Parse(symbolContainsHole.ToString()); } if (label == "Colour") { drawingBolt.Attributes.Color = colour; } drawingBolt.Modify(); drawing.CommitChanges(); } } }
public void Modify(PropertyValueChangedEventArgs e) { string label = e.ChangedItem.Label; Drawing drawing = drawingHandler.GetActiveDrawing(); DrawingObjectEnumerator drawingObjectEnum = drawingHandler.GetDrawingObjectSelector().GetSelected(); while (drawingObjectEnum.MoveNext()) { if (drawingObjectEnum.Current is Tekla.Structures.Drawing.Mark) { Tekla.Structures.Drawing.Mark drawingMark = (Tekla.Structures.Drawing.Mark)drawingObjectEnum.Current; if (label == "FrameColour") { drawingMark.Attributes.Frame.Color = frameColour; } if (label == "FrameType") { drawingMark.Attributes.Frame.Type = (FrameTypes)Enum.Parse(typeof(FrameTypes), frameType.ToString()); } drawingMark.Modify(); drawing.CommitChanges(); } } }
public static void Run(Tekla.Technology.Akit.IScript akit) { try { Model model = new Model(); DrawingHandler drawingHandler = new DrawingHandler(); DrawingObjectEnumerator drawingObjectEnum = drawingHandler.GetDrawingObjectSelector().GetSelected(); ArrayList ModelObjectArray = new ArrayList(); if (drawingObjectEnum.GetSize() > 0) { while (drawingObjectEnum.MoveNext()) { if (drawingObjectEnum.Current is Tekla.Structures.Drawing.Part) { Tekla.Structures.Drawing.Part part = drawingObjectEnum.Current as Tekla.Structures.Drawing.Part; ModelObjectArray.Add(model.SelectModelObject(new Identifier(part.ModelIdentifier.ID))); } if (drawingObjectEnum.Current is Tekla.Structures.Drawing.Bolt) { Tekla.Structures.Drawing.Bolt bolt = drawingObjectEnum.Current as Tekla.Structures.Drawing.Bolt; ModelObjectArray.Add(model.SelectModelObject(new Identifier(bolt.ModelIdentifier.ID))); } } } Tekla.Structures.Model.UI.ModelObjectSelector modelObjectSelector = new Tekla.Structures.Model.UI.ModelObjectSelector(); modelObjectSelector.Select(ModelObjectArray); akit.Callback("acmd_display_selected_object_dialog", "", "main_frame"); } catch { } }
public static void Run(Tekla.Technology.Akit.IScript akit) { try { Model model = new Model(); DrawingHandler drawingHandler = new DrawingHandler(); ArrayList ModelObjectArray = new ArrayList(); if (drawingHandler.GetActiveDrawing() != null) { DrawingObjectEnumerator drawingObjectEnum = drawingHandler.GetDrawingObjectSelector().GetSelected(); while (drawingObjectEnum.MoveNext()) { Tekla.Structures.Drawing.ModelObject dModelObject = (Tekla.Structures.Drawing.ModelObject)drawingObjectEnum.Current; ModelObjectArray.Add(model.SelectModelObject(dModelObject.ModelIdentifier)); } } else { ModelObjectEnumerator modelObjectEnum = model.GetModelObjectSelector().GetSelectedObjects(); while (modelObjectEnum.MoveNext()) { Tekla.Structures.Model.ModelObject modelObject = (Tekla.Structures.Model.ModelObject)modelObjectEnum.Current; ModelObjectArray.Add(model.SelectModelObject(modelObject.Identifier)); } } Tekla.Structures.Model.UI.ModelObjectSelector modelObjectSelector = new Tekla.Structures.Model.UI.ModelObjectSelector(); modelObjectSelector.Select(ModelObjectArray); akit.Callback("acmdCreateViewBySelectedObjectsExtrema", "", "main_frame"); akit.Callback("acmd_interrupt", "", "main_frame"); } catch { } }
public void Modify(PropertyValueChangedEventArgs e) { string label = e.ChangedItem.Label; Drawing drawing = drawingHandler.GetActiveDrawing(); DrawingObjectEnumerator drawingObjectEnum = drawingHandler.GetDrawingObjectSelector().GetSelected(); while (drawingObjectEnum.MoveNext()) { if (drawingObjectEnum.Current is Tekla.Structures.Drawing.Symbol) { Tekla.Structures.Drawing.Symbol drawingSymbol = (Tekla.Structures.Drawing.Symbol)drawingObjectEnum.Current; if (label == "Angle") drawingSymbol.Attributes.Angle = double.Parse(angle); if (label == "Colour") drawingSymbol.Attributes.Color = colour; if (label == "FrameColour") drawingSymbol.Attributes.Frame.Color = frameColour; if (label == "FrameType") drawingSymbol.Attributes.Frame.Type = (FrameTypes)Enum.Parse(typeof(FrameTypes), frameType.ToString()); if (label == "SymbolHeight") drawingSymbol.Attributes.Height = double.Parse(height); if (label == "PlacingType") { if (placingType == PlacingTypeEnum.PointPlacing) drawingSymbol.Placing = PlacingTypes.PointPlacing(); else if (placingType == PlacingTypeEnum.LeaderLinePlacing) drawingSymbol.Placing = PlacingTypes.LeaderLinePlacing(drawingSymbol.InsertionPoint); } if (label == "SymbolFile") drawingSymbol.SymbolInfo.SymbolFile = symbolFile; if (label == "SymbolIndex") drawingSymbol.SymbolInfo.SymbolIndex = int.Parse(symbolIndex); drawingSymbol.Modify(); drawing.CommitChanges(); } } }
/// <summary> /// 绘制门式框架结构中选择的多张图纸; /// </summary> public void DrawSelectListDrawingDoor() { DrawingHandler drawingHandler = new DrawingHandler(); foreach (CMrAssemblyDrawing mrDrawing in mrAssemblyDrawingList) { AssemblyDrawing assemblyDrawing = mrDrawing.mAssemblyDring; Identifier assemblyDrawingIdentifier = assemblyDrawing.AssemblyIdentifier; if (assemblyDrawing == null) { continue; } try { Assembly assembly = new Assembly { Identifier = assemblyDrawing.AssemblyIdentifier }; assembly.Select(); Identifier identifier = assembly.GetMainPart().Identifier; Beam modelObject = mModel.SelectModelObject(identifier) as Beam; drawingHandler.SetActiveDrawing(assemblyDrawing, true); DrawingObjectEnumerator allViews = assemblyDrawing.GetSheet().GetAllViews(); while (allViews.MoveNext()) { if (allViews.Current != null) { TSD.View view = allViews.Current as TSD.View; if (view != null) { DrawDrawingDoorByView(view, modelObject, mrDrawing.mDimType); } } } assemblyDrawing.IsFrozen = true; assemblyDrawing.PlaceViews(); assemblyDrawing.Modify(); drawingHandler.SaveActiveDrawing(); drawingHandler.CloseActiveDrawing(); } catch (System.Exception ex) { string strName = assemblyDrawing.Name; MessageBox.Show("图纸" + strName + "标注失败,请确认模型或图纸内是否有问题。异常信息:" + ex.Message); drawingHandler.SaveActiveDrawing(); drawingHandler.CloseActiveDrawing(); continue; } } MessageBox.Show("扬州Tekla培训石头哥提示您标注结束,感谢您对智能标注系统的支持。"); }
/// <summary> /// 删除所有的剖面标记; /// </summary> private void DeleteAllSectionMark() { DrawingObjectEnumerator allMarks = mFrontView.GetAllObjects(typeof(TSD.SectionMark)); while (allMarks.MoveNext()) { SectionMark markInDrawing = allMarks.Current as SectionMark; markInDrawing.Delete(); } }
/// <summary>Adds items from the enumerator to the System.Collections.Generic.List</summary> public static List <DrawingObject> ToList(this DrawingObjectEnumerator enumerator) { var output = new List <DrawingObject>(enumerator.GetSize()); while (enumerator.MoveNext()) { output.Add(enumerator.Current); } return(output); }
public void GetProperties() { DrawingObjectEnumerator drawingObjectEnum = drawingHandler.GetDrawingObjectSelector().GetSelected(); if (drawingObjectEnum.GetSize() == 1) { while (drawingObjectEnum.MoveNext()) { if (drawingObjectEnum.Current is Tekla.Structures.Drawing.View) { Tekla.Structures.Drawing.View drawingView = (Tekla.Structures.Drawing.View)drawingObjectEnum.Current; scale = drawingView.Attributes.Scale.ToString("F02"); sizeXMin = drawingView.RestrictionBox.MinPoint.X.ToString("F02"); sizeXMax = drawingView.RestrictionBox.MaxPoint.X.ToString("F02"); sizeYMin = drawingView.RestrictionBox.MinPoint.Y.ToString("F02"); sizeYMax = drawingView.RestrictionBox.MaxPoint.Y.ToString("F02"); sizeDepthDown = Math.Abs(drawingView.RestrictionBox.MinPoint.Z).ToString("F02"); sizeDepthUp = drawingView.RestrictionBox.MaxPoint.Z.ToString("F02"); viewExtension = drawingView.Attributes.ViewExtensionForNeighbourParts.ToString("F02"); if (drawingView.Attributes.FixedViewPlacing) { fixedViewPlacing = Bool.True; } else { fixedViewPlacing = Bool.False; } if (drawingView.Attributes.Shortening.CutParts) { cutParts = Bool.True; } else { cutParts = Bool.False; } minimumLength = drawingView.Attributes.Shortening.MinimumLength.ToString("F02"); } } } else if (drawingObjectEnum.GetSize() > 1) { scale = ""; sizeXMin = ""; sizeXMax = ""; sizeYMin = ""; sizeYMax = ""; sizeDepthDown = ""; sizeDepthUp = ""; viewExtension = ""; fixedViewPlacing = new Bool(); cutParts = new Bool(); minimumLength = ""; } }
public static void Run(Tekla.Technology.Akit.IScript akit) { DrawingHandler DrawingHandler = new DrawingHandler(); Drawing Drawing = DrawingHandler.GetActiveDrawing(); DrawingObjectEnumerator DrawingObjEnum = Drawing.GetSheet().GetAllObjects(); ArrayList MarkArray = new ArrayList(); ArrayList PartArray = new ArrayList(); while (DrawingObjEnum.MoveNext()) { if (DrawingObjEnum.Current is MarkBase) { MarkArray.Add(DrawingObjEnum.Current); } if (DrawingObjEnum.Current is Tekla.Structures.Drawing.Part || DrawingObjEnum.Current is Tekla.Structures.Drawing.Bolt) { PartArray.Add(DrawingObjEnum.Current); } } DrawingHandler.GetDrawingObjectSelector().SelectObjects(MarkArray, true); // part mark properties akit.Callback("acmd_display_selected_drawing_object_dialog", "", "main_frame"); akit.TabChange("pmark_dial", "Container_2", "gr_mark_general_tab"); akit.PushButton("gr_pmark_place", "pmark_dial"); akit.ValueChange("pmpl_dial", "text_placing_mode", "1"); akit.PushButton("txpl_modify", "pmpl_dial"); akit.PushButton("txpl_cancel", "pmpl_dial"); akit.PushButton("pmark_cancel", "pmark_dial"); // bolt mark properties akit.Callback("acmd_display_attr_dialog", "smark_dial", "main_frame"); akit.TabChange("smark_dial", "Container_217", "gr_mark_general_tab"); akit.PushButton("gr_smark_place", "smark_dial"); akit.ValueChange("smpl_dial", "text_placing_mode", "1"); akit.PushButton("txpl_modify", "smpl_dial"); akit.PushButton("txpl_cancel", "smpl_dial"); akit.PushButton("smark_cancel", "smark_dial"); // connection mark properties akit.Callback("acmd_display_attr_dialog", "jmark_dial", "main_frame"); akit.TabChange("jmark_dial", "Container_217", "gr_mark_general_tab"); akit.PushButton("gr_jmark_place", "jmark_dial"); akit.ValueChange("jmpl_dial", "text_placing_mode", "1"); akit.PushButton("txpl_modify", "jmpl_dial"); akit.PushButton("txpl_cancel", "jmpl_dial"); akit.PushButton("jmark_cancel", "jmark_dial"); DrawingHandler.GetDrawingObjectSelector().UnselectAllObjects(); DrawingHandler.GetDrawingObjectSelector().SelectObjects(PartArray, true); akit.Callback("acmd_update_marks_selected", "", "main_frame"); }
/// <summary>Adds items from the enumerator to the System.Collections.Generic.List. if (enumerator.Current is T t) output.Add(t);</summary> public static List <T> ToList <T>(this DrawingObjectEnumerator enumerator) where T : DrawingObject { var output = new List <T>(enumerator.GetSize()); while (enumerator.MoveNext()) { if (enumerator.Current is T t) { output.Add(t); } } return(output); }
private void GetIdNumbers_Click(object sender, EventArgs e) { 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); } if (drawingObjectEnumerator.Current is Tekla.Structures.Drawing.Bolt) { Tekla.Structures.Drawing.Bolt bolt = drawingObjectEnumerator.Current as Tekla.Structures.Drawing.Bolt; SelectedObjectArray.Add(model.SelectModelObject(new Identifier(bolt.ModelIdentifier.ID))); DrawingObjectArray.Add(bolt); } } 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; MarkArray.Add(modelPart.Identifier.ID.ToString()); } if (modelObjectEnumerator.Current is Tekla.Structures.Model.BoltGroup) { Tekla.Structures.Model.BoltGroup modelBolt = modelObjectEnumerator.Current as Tekla.Structures.Model.BoltGroup; MarkArray.Add(modelBolt.Identifier.ID.ToString()); } } MarkArray.Sort(); string MarkList = ""; foreach (string strMark in MarkArray) { MarkList = strMark + " " + MarkList; } Clipboard.SetDataObject(MarkList); richTextBox1.Text = MarkList; drawingHandler.GetDrawingObjectSelector().SelectObjects(DrawingObjectArray, false); }
public void GetProperties() { DrawingObjectEnumerator drawingObjectEnum = drawingHandler.GetDrawingObjectSelector().GetSelected(); if (drawingObjectEnum.GetSize() == 1) { while (drawingObjectEnum.MoveNext()) { if (drawingObjectEnum.Current is Tekla.Structures.Drawing.Weld) { Tekla.Structures.Drawing.Weld drawingWeld = (Tekla.Structures.Drawing.Weld)drawingObjectEnum.Current; } } } }
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 void Modify(PropertyValueChangedEventArgs e) { string label = e.ChangedItem.Label; Drawing drawing = drawingHandler.GetActiveDrawing(); DrawingObjectEnumerator drawingObjectEnum = drawingHandler.GetDrawingObjectSelector().GetSelected(); while (drawingObjectEnum.MoveNext()) { if (drawingObjectEnum.Current is Tekla.Structures.Drawing.Weld) { Tekla.Structures.Drawing.Weld drawingWeld = (Tekla.Structures.Drawing.Weld)drawingObjectEnum.Current; drawingWeld.Modify(); drawing.CommitChanges(); } } }
//This method gets the pciked object ID and selecs it in the model, showing //some of its information in the form private void GetInfoFromDrawing(DrawingObject pickedObject) { modelObjectTextBox.Clear(); if (pickedObject != null) { TSD.ModelObject modelObjectInDrawing = pickedObject as TSD.ModelObject; if (modelObjectInDrawing != null) { TSM.ModelObject modelObjectInModel = _model.SelectModelObject(modelObjectInDrawing.ModelIdentifier); if (modelObjectInModel is TSM.RebarGroup || modelObjectInModel is TSM.Reinforcement) { Reinforcement beam = modelObjectInModel as Reinforcement; if (beam != null) { double radius = double.Parse(beam.RadiusValues[0].ToString()); Solid sol = beam.GetSolid(); double maxX = sol.MaximumPoint.X; double maxY = sol.MaximumPoint.Y; double maxZ = sol.MaximumPoint.Z; double minX = sol.MinimumPoint.X; double minY = sol.MinimumPoint.Y; double minZ = sol.MinimumPoint.Z; // start vẽ polyline Polyline MyPolyline; PointList PolygonPoints = new PointList(); for (double i = maxY - radius; i <= maxY; i += 1) { PolygonPoints.Add(new g3d.Point(i, i)); } DrawingObjectEnumerator views = _drawingHandler.GetActiveDrawing().GetSheet().GetAllViews(); while (views.MoveNext()) { MyPolyline = new Polyline(views.Current as ViewBase, PolygonPoints); MyPolyline.Insert(); } GetBeamInfo(beam); //end vẽ đường thẳng } } } } }
public static void Run(Tekla.Technology.Akit.IScript akit) { Model model = new Model(); DrawingHandler drawingHandler = new DrawingHandler(); DrawingEnumerator drawingEnum = drawingHandler.GetDrawingSelector().GetSelected(); if (drawingHandler.GetActiveDrawing() == null) { while (drawingEnum.MoveNext()) { if (drawingEnum.Current is AssemblyDrawing) { AssemblyDrawing assemblyDrawing = drawingEnum.Current as AssemblyDrawing; drawingHandler.SetActiveDrawing(assemblyDrawing, false); DrawingObjectEnumerator drawingObjectEnum = drawingHandler.GetActiveDrawing().GetSheet().GetAllObjects(); while (drawingObjectEnum.MoveNext()) { if (drawingObjectEnum.Current is Tekla.Structures.Drawing.Part) { Tekla.Structures.Drawing.Part part = drawingObjectEnum.Current as Tekla.Structures.Drawing.Part; ArrayList array = new ArrayList(); array.Add(model.SelectModelObject(new Tekla.Structures.Identifier(part.ModelIdentifier.ID))); Tekla.Structures.Model.UI.ModelObjectSelector modelObjectSelector = new Tekla.Structures.Model.UI.ModelObjectSelector(); modelObjectSelector.Select(array); ModelObjectEnumerator modelObjectEnum = model.GetModelObjectSelector().GetSelectedObjects(); while (modelObjectEnum.MoveNext()) { if (modelObjectEnum.Current is Tekla.Structures.Model.Part) { Tekla.Structures.Model.Part mpart = modelObjectEnum.Current as Tekla.Structures.Model.Part; Tekla.Structures.Model.Assembly assembly = mpart.GetAssembly(); Tekla.Structures.Model.Part mainPart = (Tekla.Structures.Model.Part)assembly.GetMainPart(); assemblyDrawing.Name = mainPart.Name; assemblyDrawing.Modify(); assemblyDrawing.CommitChanges(); } } modelObjectSelector.Select(new ArrayList()); } } drawingHandler.CloseActiveDrawing(); } } } }
private void button1_Click(object sender, EventArgs e) { /* Model model = new Model(); * BinaryFilterExpression filterExpression = new BinaryFilterExpression(new TemplateFilterExpressions.CustomString("PROFILE"),StringOperatorType.IS_EQUAL, new StringConstantFilterExpression("HEB200")); * * Tekla.Structures.Model.UI.ModelObjectSelector mos = new Tekla.Structures.Model.UI.ModelObjectSelector(); * * ModelObjectEnumerator moe = model.GetModelObjectSelector().GetObjectsByFilter(filterExpression);*/ StreamWriter sw = new StreamWriter(textBox1.Text); DrawingHandler Dh = new DrawingHandler(); Drawing CurrentDrawing = Dh.GetActiveDrawing(); DrawingObjectEnumerator Doe = CurrentDrawing.GetSheet().GetAllObjects(); while (Doe.MoveNext()) { Mark PartMark = Doe.Current as Mark; if (PartMark == null) { continue; } if (PartMark.Attributes.Content.Count > 1) { // PartMark.Delete(); DrawingObjectEnumerator Related = PartMark.GetRelatedObjects(); while (Related.MoveNext()) { Part DrawingPart = Related.Current as Part; if (DrawingPart == null) { continue; } Tekla.Structures.Model.Beam ModelPart = new Tekla.Structures.Model.Beam(); ModelPart.Identifier = DrawingPart.ModelIdentifier; string PropValue = string.Empty; ModelPart.GetReportProperty("PART_POS", ref PropValue); sw.WriteLine("'" + PropValue); } } } sw.Close(); }
public void GetProperties() { DrawingObjectEnumerator drawingObjectEnum = drawingHandler.GetDrawingObjectSelector().GetSelected(); if (drawingObjectEnum.GetSize() == 1) { while (drawingObjectEnum.MoveNext()) { if (drawingObjectEnum.Current is Tekla.Structures.Drawing.Bolt) { Tekla.Structures.Drawing.Bolt drawingBolt = (Tekla.Structures.Drawing.Bolt)drawingObjectEnum.Current; boltRepresentation = drawingBolt.Attributes.Representation; if (drawingBolt.Attributes.SymbolContainsAxis) { symbolContainsAxis = Bool.True; } else { symbolContainsAxis = Bool.False; } if (drawingBolt.Attributes.SymbolContainsHole) { symbolContainsHole = Bool.True; } else { symbolContainsHole = Bool.False; } colour = drawingBolt.Attributes.Color; } } } else if (drawingObjectEnum.GetSize() > 1) { boltRepresentation = new Bolt.Representation(); symbolContainsAxis = new Bool(); SymbolContainsHole = new Bool(); colour = new DrawingColors(); } }
public void GetProperties() { DrawingObjectEnumerator drawingObjectEnum = drawingHandler.GetDrawingObjectSelector().GetSelected(); if (drawingObjectEnum.GetSize() == 1) { while (drawingObjectEnum.MoveNext()) { if (drawingObjectEnum.Current is Tekla.Structures.Drawing.Mark) { Tekla.Structures.Drawing.Mark drawingMark = (Tekla.Structures.Drawing.Mark)drawingObjectEnum.Current; frameColour = drawingMark.Attributes.Frame.Color; frameType = (FrameTypeEnum)Enum.Parse(typeof(FrameTypeEnum), drawingMark.Attributes.Frame.Type.ToString()); } } } else if (drawingObjectEnum.GetSize() > 1) { frameColour = new DrawingColors(); FrameType = new FrameTypeEnum(); } }
public static void Run(Tekla.Technology.Akit.IScript akit) { DrawingHandler myDrawingHandler = new DrawingHandler(); if (myDrawingHandler.GetConnectionStatus()) { DrawingObjectEnumerator selectedObjects = myDrawingHandler.GetDrawingObjectSelector().GetSelected(); while (selectedObjects.MoveNext()) { if (selectedObjects.Current is StraightDimensionSet) { StraightDimensionSet curDimSet = selectedObjects.Current as TSD.StraightDimensionSet; TSD.ContainerElement LUT = curDimSet.Attributes.LeftUpperTag as TSD.ContainerElement; TSD.ContainerElement RUT = curDimSet.Attributes.RightUpperTag as TSD.ContainerElement; curDimSet.Attributes.LeftUpperTag = RUT; curDimSet.Attributes.RightUpperTag = LUT; curDimSet.Modify(); } } } }
/// <summary> /// Edit opened drawing, take string from dialog and write it under every view in the drawing. /// Draws also rectangle around the text string. /// </summary> private void EditOpenedDrawing() { if (MyDrawingHandler.GetConnectionStatus()) { Drawing MyDrawing = MyDrawingHandler.GetActiveDrawing(); ContainerView Sheet = MyDrawing.GetSheet(); DrawingObjectEnumerator MyViewEnumerator = Sheet.GetViews(); //Looping through views in the drawing while (MyViewEnumerator.MoveNext()) { View CurrentView = MyViewEnumerator.Current as View; //If ViewBase used instead of View, then multidrawing's container views would work here also if (CurrentView != null) { //Getting bounding box for the view frame and calculating then the CenterPoint under it RectangleBoundingBox ViewAABB = CurrentView.GetAxisAlignedBoundingBox(); Point CenterPoint = new Point(); CenterPoint.X = ViewAABB.LowerLeft.X + (ViewAABB.LowerRight.X - ViewAABB.LowerLeft.X) / 2.0; CenterPoint.Y = ViewAABB.LowerLeft.Y - 5.0; //5.0 mm below the view's bounding box Text MyViewTitle = new Text(Sheet, CenterPoint, ViewTitle.Text, new Text.TextAttributes()); if (!MyViewTitle.Insert()) { Console.WriteLine("Insert failed."); } else { RectangleBoundingBox TitleAABB = MyViewTitle.GetAxisAlignedBoundingBox(); Rectangle myBox = new Rectangle(Sheet, TitleAABB.LowerLeft, TitleAABB.UpperRight); myBox.Insert(); } } } MyDrawing.CommitChanges(); } }
public void GetProperties() { DrawingObjectEnumerator drawingObjectEnum = drawingHandler.GetDrawingObjectSelector().GetSelected(); if (drawingObjectEnum.GetSize() == 1) { while (drawingObjectEnum.MoveNext()) { if (drawingObjectEnum.Current is Tekla.Structures.Drawing.Symbol) { Tekla.Structures.Drawing.Symbol drawingSymbol = (Tekla.Structures.Drawing.Symbol)drawingObjectEnum.Current; angle = drawingSymbol.Attributes.Angle.ToString(); colour = drawingSymbol.Attributes.Color; frameColour = drawingSymbol.Attributes.Frame.Color; frameType = (FrameTypeEnum)Enum.Parse(typeof(FrameTypeEnum), drawingSymbol.Attributes.Frame.Type.ToString()); height = drawingSymbol.Attributes.Height.ToString(); insertionPoint = drawingSymbol.InsertionPoint; string placing = drawingSymbol.Placing.ToString().Replace("Tekla.Structures.Drawing.", ""); placingType = (PlacingTypeEnum)Enum.Parse(typeof(PlacingTypeEnum), placing); symbolFile = drawingSymbol.SymbolInfo.SymbolFile; symbolIndex = drawingSymbol.SymbolInfo.SymbolIndex.ToString(); } } } else if (drawingObjectEnum.GetSize() > 1) { angle = ""; colour = new DrawingColors(); frameColour = new DrawingColors(); frameType = new FrameTypeEnum(); height = ""; insertionPoint = null; placingType = new PlacingTypeEnum(); symbolFile = ""; symbolIndex = ""; } }
/// <summary> /// 初始化柱子的轴线; /// </summary> private void InitCylinderGridLine() { if (null == mViewBase) { return; } DrawingObjectEnumerator gridLines = mViewBase.GetAllObjects(typeof(TSD.GridLine)); DrawingHandler drawingHandler = new DrawingHandler(); TSD.UI.DrawingObjectSelector DS = drawingHandler.GetDrawingObjectSelector(); while (gridLines.MoveNext()) { GridLine gridLine = gridLines.Current as GridLine; if (gridLine == null) { continue; } Point startPoint = gridLine.StartLabel.CenterPoint; Point endPoint = gridLine.EndLabel.CenterPoint; Vector gridlineDirectionNormal = new Vector(endPoint.X - startPoint.X, endPoint.Y - startPoint.Y, endPoint.Z - startPoint.Z); if (!CDimTools.GetInstance().IsTwoVectorParallel(gridlineDirectionNormal, new Vector(1, 0, 0))) { continue; } Point intersectionPoint = CDimTools.GetInstance().ComputeTwoLineIntersectPoint(startPoint, endPoint, new Point(0, 0, 0), new Point(0, 1000, 0)); mIntersectionPointList.Add(intersectionPoint); } }
public static void Run(Tekla.Technology.Akit.IScript akit) { try { Model model = new Model(); DrawingHandler drawingHandler = new DrawingHandler(); Drawing drawing = drawingHandler.GetActiveDrawing(); if (drawing != null) { Tekla.Structures.Drawing.StraightDimension sd = null; Tekla.Structures.Drawing.Bolt bolt = null; DrawingObjectEnumerator drawingObjectEnum = drawingHandler.GetDrawingObjectSelector().GetSelected(); while (drawingObjectEnum.MoveNext()) { if (drawingObjectEnum.Current is Tekla.Structures.Drawing.StraightDimension) { sd = (Tekla.Structures.Drawing.StraightDimension)drawingObjectEnum.Current; } if (drawingObjectEnum.Current is Tekla.Structures.Drawing.Bolt) { bolt = (Tekla.Structures.Drawing.Bolt)drawingObjectEnum.Current; } } if (bolt == null) { Tekla.Structures.Drawing.UI.Picker picker = drawingHandler.GetPicker(); DrawingObject drawingObject = null; Tekla.Structures.Drawing.ViewBase viewBase = null; Tekla.Structures.Geometry3d.Point pickedPoint = null; Type[] TypeFilter = new Type[] { typeof(Tekla.Structures.Drawing.Bolt) }; picker.PickObject("pick bolt", TypeFilter, out drawingObject, out viewBase, out pickedPoint); bolt = (Tekla.Structures.Drawing.Bolt)drawingObject; } Tekla.Structures.Model.BoltGroup mBolt = (Tekla.Structures.Model.BoltGroup)model.SelectModelObject((Identifier)bolt.ModelIdentifier); string note = ""; if (mBolt is BoltArray) { BoltArray boltArray = (BoltArray)mBolt; if (boltArray.GetBoltDistYCount() == 1 && boltArray.GetBoltDistY(0) == 0) { note = (mBolt.BoltPositions.Count - 1).ToString() + " No SPACES @ " + boltArray.GetBoltDistX(1).ToString() + " = "; } if (boltArray.GetBoltDistY(0) > 0) { } } else if (mBolt is BoltXYList) { BoltXYList boltXYList = (BoltXYList)mBolt; note = (boltXYList.BoltPositions.Count - 1).ToString() + " STAGGERED No SPACES @ " + (boltXYList.GetBoltDistX(1)).ToString() + " = "; } Tekla.Structures.Drawing.UI.DrawingObjectSelector drawingObjectSelector = drawingHandler.GetDrawingObjectSelector(); drawingObjectSelector.SelectObject(sd); akit.ValueChange("main_frame", "gr_sel_dimension", "1"); akit.Callback("acmd_display_attr_dialog", "dim_dial", "main_frame"); akit.PushButton("dim_set", "dim_dial"); akit.TabChange("dim_dial", "tabWndDimAttrib", "tabMarks"); akit.PushButton("dim_on_off", "dim_dial"); akit.ValueChange("dim_dial", "txtFldPrefix", note); akit.PushButton("dim_modify", "dim_dial"); akit.PushButton("dim_cancel", "dim_dial"); } } catch { } }
/// <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); } } }