//Pick a part from the drawing, to get its information //from the model private void PickObjectInDrawing_Click(object sender, EventArgs e) { try { _drawing = _drawingHandler.GetActiveDrawing(); //Checks if any drawing is open if (_drawing != null) { DrawingObject pickedObject; ViewBase pickedView; Tekla.Structures.Geometry3d.Point pickedPoint; //Pick a part in the model Picker myPicker = _drawingHandler.GetPicker(); myPicker.PickObject("Pick a model object in the drawing", out pickedObject, out pickedView, out pickedPoint); GetInfoFromDrawing(pickedObject); } else { MessageBox.Show("A drawing must be opened in Tekla Structures model!"); } } catch (Exception exc) { MessageBox.Show(exc.ToString()); } }
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 void Run(Tekla.Technology.Akit.IScript akit) { //Idea is to get only objects in selected view ViewBase view; DrawingObject dob; var handler = new DrawingHandler(); Picker picker = handler.GetPicker(); picker.PickObject("Select any object in intended view", out dob, out view); var reinforcement = view.GetAllObjects(typeof(ReinforcementBase)); DrawingHandler.SetMessageExecutionStatus(DrawingHandler.MessageExecutionModeEnum.BY_COMMIT); foreach (ReinforcementBase reinf in reinforcement) { if (reinf.Hideable.IsHidden) { reinf.Hideable.ShowInDrawingView(); reinf.Modify(); } } DrawingHandler.SetMessageExecutionStatus(DrawingHandler.MessageExecutionModeEnum.INSTANT); handler.GetActiveDrawing().CommitChanges(); Tekla.Structures.Model.Operations.Operation.DisplayPrompt("Operation finished"); }
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(); } } }
/// <summary> /// Executes a macro in the view. /// </summary> /// <param name="macroName">Macro name.</param> public void RunMacro(string macroName) { Model CurrentModel = new Model(); DrawingHandler DrawingHandler = new DrawingHandler(); if (DrawingHandler.GetActiveDrawing() != null) { macroName = @"..\drawings\" + macroName; } if (CurrentModel.GetConnectionStatus()) { if (!Path.HasExtension(macroName)) { macroName += ".cs"; } while (Operation.IsMacroRunning()) { Thread.Sleep(100); } Operation.RunMacro(macroName); } }
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 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 { } }
/// <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 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.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 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(); } } }
public static void Run(Tekla.Technology.Akit.IScript akit) { var handler = new DrawingHandler(); var selection = handler.GetDrawingObjectSelector().GetSelected(); DrawingHandler.SetMessageExecutionStatus(DrawingHandler.MessageExecutionModeEnum.BY_COMMIT); double rotang = 0; while (selection.MoveNext()) { if (selection.Current is MarkBase) { MarkBase mark = selection.Current as MarkBase; mark.Attributes.RotationAngle = rotang; mark.Attributes.PlacingAttributes.IsFixed = true; mark.Modify(); } else { Text text = selection.Current as Text; text.Attributes.Angle = rotang; text.Attributes.PlacingAttributes.IsFixed = true; text.Modify(); } } DrawingHandler.SetMessageExecutionStatus(DrawingHandler.MessageExecutionModeEnum.INSTANT); handler.GetActiveDrawing().CommitChanges(); }
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(); } } } }
public void Example1() { DrawingHandler MyDrawingHandler = new DrawingHandler(); ViewBase _view = MyDrawingHandler.GetActiveDrawing().GetSheet().GetAllViews().Current as ViewBase; EmbeddedObjectAttributes attributes = new EmbeddedObjectAttributes(); attributes.XScale = 0.5; attributes.YScale = 0.5; DwgObject dxf = new DwgObject(_view, new Point(100, 100), Path.GetFullPath("my_dxf.dxf"), attributes); dxf.Insert(); }
public void GetProperties() { Drawing drawing = drawingHandler.GetActiveDrawing(); name = drawing.Name; title1 = drawing.Title1; title2 = drawing.Title2; title3 = drawing.Title3; height = drawing.Layout.SheetSize.Height.ToString(); width = drawing.Layout.SheetSize.Width.ToString(); drawing.GetUserProperty("DR_DRAWN_BY", ref drawnBy); drawing.GetUserProperty("DR_CHECKED_BY", ref checkedBy); drawing.GetUserProperty("DRAWING_USERFIELD_1", ref userfield1); drawing.GetUserProperty("DRAWING_USERFIELD_2", ref userfield2); drawing.GetUserProperty("DRAWING_USERFIELD_3", ref userfield3); drawing.GetUserProperty("DRAWING_USERFIELD_4", ref userfield4); drawing.GetUserProperty("DRAWING_USERFIELD_5", ref userfield5); drawing.GetUserProperty("DRAWING_USERFIELD_6", ref userfield6); drawing.GetUserProperty("DRAWING_USERFIELD_7", ref userfield7); drawing.GetUserProperty("DRAWING_USERFIELD_8", ref userfield8); }
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"); }
static void Main() { try { DrawingHandler drawingHandler = new DrawingHandler(); if (drawingHandler.GetConnectionStatus()) { Drawing CurrentDrawing = drawingHandler.GetActiveDrawing(); if (CurrentDrawing != null) { DrawingObjectEnumerator drawingObjectEnumerator = CurrentDrawing.GetSheet().GetAllObjects(typeof(Part)); foreach (Part myPart in drawingObjectEnumerator) { View view = myPart.GetView() as View; TransformationPlane SavePlane = new Model().GetWorkPlaneHandler().GetCurrentTransformationPlane(); new Model().GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane(view.DisplayCoordinateSystem)); Identifier Identifier = myPart.ModelIdentifier; ModelObject modelObject = new Model().SelectModelObject(Identifier); PointList PointList = new PointList(); Beam myBeam = new Beam(); if (modelObject.GetType().Equals(typeof(Beam))) { myBeam.Identifier = Identifier; myBeam.Select(); PointList.Add(myBeam.StartPoint); PointList.Add(myBeam.EndPoint); } ViewBase viewBase = myPart.GetView(); StraightDimensionSet.StraightDimensionSetAttributes attr = new StraightDimensionSet.StraightDimensionSetAttributes(myPart); if (myBeam.StartPoint.X != myBeam.EndPoint.X) { StraightDimensionSet XDimensions = new StraightDimensionSetHandler().CreateDimensionSet(viewBase, PointList, new Vector(0, 100, 0), 100, attr); XDimensions.Insert(); } new Model().GetWorkPlaneHandler().SetCurrentTransformationPlane(SavePlane); } } } } catch (Exception EX) { Console.WriteLine("Exception : " + EX.ToString()); } }
public string GetActiveMultiInfo() { string result = string.Empty; DrawingHandler drawingHandler = new DrawingHandler(); Drawing drawing = drawingHandler.GetActiveDrawing(); string title2 = string.Empty; drawing.GetUserProperty("PM_DRAWING_TITLE_2", ref title2); return(title2); }
public static void Run(Tekla.Technology.Akit.IScript akit) { //This will reveall objects in all views in drawing DrawingHandler DrawingHandler = new DrawingHandler(); Drawing CurrentDrawing = DrawingHandler.GetActiveDrawing(); DrawingObjectEnumerator dimensions = CurrentDrawing.GetSheet().GetAllObjects(typeof(ReinforcementBase)); DrawingHandler.SetMessageExecutionStatus(DrawingHandler.MessageExecutionModeEnum.BY_COMMIT); foreach (ReinforcementBase reinf in dimensions) { if (reinf.Hideable.IsHidden) { //dim.Delete(); reinf.Hideable.ShowInDrawingView(); reinf.Modify(); } } DrawingHandler.SetMessageExecutionStatus(DrawingHandler.MessageExecutionModeEnum.INSTANT); DrawingHandler.GetActiveDrawing().CommitChanges(); Tekla.Structures.Model.Operations.Operation.DisplayPrompt("Operation finished"); }
private void button1_Click(object sender, EventArgs e) { // select objects ArrayList array = new ArrayList(); DrawingHandler drawingHandler = new DrawingHandler(); Drawing drawing = drawingHandler.GetActiveDrawing(); ContainerView containerView = drawing.GetSheet(); DrawingObjectEnumerator drawingObjEnum = containerView.GetObjects(); foreach (DrawingObject dobj in drawingObjEnum) { array.Add(dobj); } drawingHandler.GetDrawingObjectSelector().SelectObjects(array, 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(); } } }
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(); }
private void button1_Click(object sender, EventArgs e) { DrawingHandler drawingHandler = new DrawingHandler(); Drawing drawing = drawingHandler.GetActiveDrawing(); if (drawing == null) { int number = int.Parse(textBox1.Text); for (int i = 1; i <= number; i++) { Tekla.Structures.Drawing.Size size = new Tekla.Structures.Drawing.Size(410, 287); Tekla.Structures.Drawing.Drawing newGADrawing = new GADrawing("standard", size); newGADrawing.Insert(); } } else { MessageBox.Show("Close active drawing first"); } }
/// <summary> /// 框架结构的一键标注; /// </summary> /// <param name="nType"></param> public void CreateAutoSectionTest(string strDimType, int nFlag) { 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(); if (nFlag == 0) { Identifier identifier = assembly.GetMainPart().Identifier; TSM.Part modelObject = mModel.SelectModelObject(identifier) as TSM.Part; CreateAutoSection(strDimType, modelObject, assemblyDrawing); } else if (nFlag == 1) { Identifier identifier = assembly.GetMainPart().Identifier; TSM.Part modelObject = mModel.SelectModelObject(identifier) as TSM.Part; CreateAutoSectionDoor(strDimType, modelObject, assemblyDrawing); } } catch (Exception e) { MessageBox.Show(e.Message); } }
private void BtnApply_Click(object sender, EventArgs e) { lbCode.Text = ""; lbResult.Text = ""; SelectedDrawings = new List <Drawing>(); progressBar1.Value = 0; CD.DetailName = cbCode.Text; if (chkAutoApply.Checked) { if (btnApply.Text == "Apply") { DrawingHandler dh = new DrawingHandler(); SelectedDrawings = Com.EnumtoArrayDr(dh.GetDrawingSelector().GetSelected()).OfType <TSD.Drawing>().ToList().OrderBy(x => x.Title1).ToList(); if (SelectedDrawings?.Count > 0) { progressBar1.Maximum = SelectedDrawings.Count; btnApply.Text = "Cancel"; workerThread.RunWorkerAsync(); } else { lbResult.Text = "Please Select Drawings!!"; } } else { workerThread.CancelAsync(); } } else { DrawingHandler dh = new DrawingHandler(); TSD.Drawing Dr = dh.GetActiveDrawing(); if (Dr != null) { CD.ProceedDrawing(Dr, chkDeleteDim.Checked, lbCode); } } }
/// <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(); } }
/// <summary> /// 初始化主梁对象; /// </summary> /// <returns></returns> private void InitMainPart() { DrawingHandler drawingHandler = new DrawingHandler(); if (mModel.GetConnectionStatus() && drawingHandler.GetConnectionStatus()) { DrawingHandler.SetMessageExecutionStatus(DrawingHandler.MessageExecutionModeEnum.INSTANT); AssemblyDrawing assemblyDrawing = drawingHandler.GetActiveDrawing() as AssemblyDrawing; if (assemblyDrawing != null) { Assembly assembly = new Assembly { Identifier = assemblyDrawing.AssemblyIdentifier }; assembly.Select(); TSM.Part mainPart = assembly.GetMainPart() as TSM.Part; //创建自定义的主梁对象; CMrMainBeam mainBeam = new CMrMainBeam(mainPart, null); CMrMainBeam.SetInstance(mainBeam); double dblFlangeThickness = 0.0; double dblWebThickness = 0.0; //assembly.GetMainPart().GetReportProperty(CDogTools.GetInstance().GetFLANGEStr(), ref dblFlangeThickness);//YB 01 101 6 PROFILE.FLANGE_THICKNESS //assembly.GetMainPart().GetReportProperty(CDogTools.GetInstance().GetWEBStr(), ref dblWebThickness); //111 6 PROFILE.WEB_THICKNESS assembly.GetMainPart().GetReportProperty("PROFILE.FLANGE_THICKNESS", ref dblFlangeThickness); assembly.GetMainPart().GetReportProperty("PROFILE.WEB_THICKNESS", ref dblWebThickness); mainBeam.mFlangeThickness = dblFlangeThickness; mainBeam.mWebThickness = dblWebThickness; } } }
private void UpdateProperties() { if (this.propertyGrid1.InvokeRequired) { UpdatePropertiesCallback d = new UpdatePropertiesCallback(UpdateProperties); this.Invoke(d); } else { Drawing drawing = drawingHandler.GetActiveDrawing(); if (drawing != null) { DrawingObjectEnumerator drawingObjectEnum = drawingHandler.GetDrawingObjectSelector().GetSelected(); statusLabel.Text = drawingObjectEnum.GetSize().ToString() + " objects selected"; ArrayList arraySelectedObjects = new ArrayList(); if (drawingObjectEnum.GetSize() == 0) { activeDrawing.GetProperties(); propertyGrid1.SelectedObject = activeDrawing; } while (drawingObjectEnum.MoveNext()) { string objectType = drawingObjectEnum.Current.GetType().ToString(); if (!arraySelectedObjects.Contains(objectType)) { arraySelectedObjects.Add(objectType); } } comboBox1.Text = ""; comboBox1.Items.Clear(); arraySelectedObjects.Sort(); foreach (string objectName in arraySelectedObjects) { comboBox1.Items.Add(objectName); } if (arraySelectedObjects.Count == 1) { if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Drawing.Part") { drawingPart.GetProperties(); propertyGrid1.SelectedObject = drawingPart; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Drawing.Weld") { drawingWeld.GetProperties(); propertyGrid1.SelectedObject = drawingWeld; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Drawing.View") { view.GetProperties(); propertyGrid1.SelectedObject = view; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Drawing.Bolt") { drawingBolt.GetProperties(); propertyGrid1.SelectedObject = drawingBolt; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Drawing.StraightDimensionSet") { straightDim.GetProperties(); propertyGrid1.SelectedObject = straightDim; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Drawing.RadiusDimension") { radiusDim.GetProperties(); propertyGrid1.SelectedObject = radiusDim; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Drawing.CurvedDimensionSetRadial") { radialDim.GetProperties(); propertyGrid1.SelectedObject = radialDim; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Drawing.AngleDimension") { angleDim.GetProperties(); propertyGrid1.SelectedObject = angleDim; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Drawing.GridLine") { drawingGrid.GetProperties(); propertyGrid1.SelectedObject = drawingGrid; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Drawing.Line") { line.GetProperties(); propertyGrid1.SelectedObject = line; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Drawing.Arc") { arc.GetProperties(); propertyGrid1.SelectedObject = arc; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Drawing.Polyline") { polyline.GetProperties(); propertyGrid1.SelectedObject = polyline; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Drawing.Rectangle") { rectangle.GetProperties(); propertyGrid1.SelectedObject = rectangle; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Drawing.Circle") { circle.GetProperties(); propertyGrid1.SelectedObject = circle; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Drawing.Polygon") { polygon.GetProperties(); propertyGrid1.SelectedObject = polygon; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Drawing.Text") { text.GetProperties(); propertyGrid1.SelectedObject = text; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Drawing.Symbol") { symbol.GetProperties(); propertyGrid1.SelectedObject = symbol; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Drawing.Mark") { mark.GetProperties(); propertyGrid1.SelectedObject = mark; } else { activeDrawing.GetProperties(); propertyGrid1.SelectedObject = activeDrawing; } comboBox1.SelectedText = arraySelectedObjects[0].ToString(); propertyGrid1.Focus(); } if (arraySelectedObjects.Count > 1) { propertyGrid1.SelectedObject = null; } } if (drawing == null) { ModelObjectEnumerator modelObjectEnum = model.GetModelObjectSelector().GetSelectedObjects(); statusLabel.Text = modelObjectEnum.GetSize().ToString() + " objects selected"; ArrayList arraySelectedObjects = new ArrayList(); if (modelObjectEnum.GetSize() == 0) { propertyGrid1.SelectedObject = null; } while (modelObjectEnum.MoveNext()) { string objectType = modelObjectEnum.Current.GetType().ToString(); if (!arraySelectedObjects.Contains(objectType)) { arraySelectedObjects.Add(objectType); } } comboBox1.Text = ""; comboBox1.Items.Clear(); arraySelectedObjects.Sort(); foreach (string objectName in arraySelectedObjects) { comboBox1.Items.Add(objectName); } if (arraySelectedObjects.Count == 0) { Tekla.Structures.Model.UI.ModelViewEnumerator modelViewEnum = Tekla.Structures.Model.UI.ViewHandler.GetSelectedViews(); if (modelViewEnum.Count == 1) { modelView.GetProperties(); propertyGrid1.SelectedObject = modelView; comboBox1.SelectedText = "Tekla.Structures.Model.UI.View"; propertyGrid1.Focus(); } } if (arraySelectedObjects.Count == 1) { if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Model.Beam") { beam.GetProperties(); propertyGrid1.SelectedObject = beam; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Model.ContourPlate") { contourPlate.GetProperties(); propertyGrid1.SelectedObject = contourPlate; } else if (arraySelectedObjects[0].ToString().Contains("Tekla.Structures.Model.Weld")) { modelWeld.GetProperties(); propertyGrid1.SelectedObject = modelWeld; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Model.PolygonWeld") { modelWeld.GetProperties(); propertyGrid1.SelectedObject = modelWeld; } else if (arraySelectedObjects[0].ToString().Contains("Tekla.Structures.Model.Bolt")) { modelBolt.GetProperties(); propertyGrid1.SelectedObject = modelBolt; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Model.Grid") { modelGrid.GetProperties(); propertyGrid1.SelectedObject = modelGrid; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Model.Connection") { modelConnection.GetProperties(); propertyGrid1.SelectedObject = modelConnection; } comboBox1.SelectedText = arraySelectedObjects[0].ToString(); propertyGrid1.Focus(); } if (arraySelectedObjects.Count > 1) { propertyGrid1.SelectedObject = null; } } } }
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.GridLine) { Tekla.Structures.Drawing.GridLine grid = (Tekla.Structures.Drawing.GridLine)drawingObjectEnum.Current; if (label == "DrawOnlyTextLabelsNotGridLines") { grid.Attributes.DrawOnlyTextLabelsNotGridLines = bool.Parse(DrawOnlyTextLabelsNotGridLines.ToString()); } if (label == "DrawTextAtEndOfGridLine") { grid.Attributes.DrawTextAtEndOfGridLine = bool.Parse(drawTextAtEndOfGridLine.ToString()); } if (label == "DrawTextAtStartOfGridLine") { grid.Attributes.DrawTextAtStartOfGridLine = bool.Parse(drawTextAtStartOfGridLine.ToString()); } if (label == "FontBold") { grid.Attributes.Font.Bold = bool.Parse(fontBold.ToString()); } if (label == "FontColour") { grid.Attributes.Font.Color = fontColour; } if (label == "FontHeight") { grid.Attributes.Font.Height = double.Parse(fontHeight); } if (label == "FontItalic") { grid.Attributes.Font.Italic = bool.Parse(fontItalic.ToString()); } if (label == "FontName") { grid.Attributes.Font.Name = fontName; } if (label == "FrameColour") { grid.Attributes.Frame.Color = frameColour; } if (label == "FrameType") { if (frameType == FrameTypeEnum.Circle) { grid.Attributes.Frame.Type = FrameTypes.Circle; } else if (frameType == FrameTypeEnum.Diamond) { grid.Attributes.Frame.Type = FrameTypes.Diamond; } else if (frameType == FrameTypeEnum.Hexagon) { grid.Attributes.Frame.Type = FrameTypes.Hexagon; } else if (frameType == FrameTypeEnum.Line) { grid.Attributes.Frame.Type = FrameTypes.Line; } else if (frameType == FrameTypeEnum.None) { grid.Attributes.Frame.Type = FrameTypes.None; } else if (frameType == FrameTypeEnum.Rectangular) { grid.Attributes.Frame.Type = FrameTypes.Rectangular; } else if (frameType == FrameTypeEnum.Round) { grid.Attributes.Frame.Type = FrameTypes.Round; } else if (frameType == FrameTypeEnum.Sharpened) { grid.Attributes.Frame.Type = FrameTypes.Sharpened; } else if (frameType == FrameTypeEnum.Triangle) { grid.Attributes.Frame.Type = FrameTypes.Triangle; } } if (label == "LineColour") { grid.Attributes.Line.Color = lineColour; } if (label == "LineType") { if (lineType == LineTypeEnum.DashDot) { grid.Attributes.Line.Type = LineTypes.DashDot; } else if (lineType == LineTypeEnum.DashDoubleDot) { grid.Attributes.Line.Type = LineTypes.DashDoubleDot; } else if (lineType == LineTypeEnum.DashedLine) { grid.Attributes.Line.Type = LineTypes.DashedLine; } else if (lineType == LineTypeEnum.DottedLine) { grid.Attributes.Line.Type = LineTypes.DottedLine; } else if (lineType == LineTypeEnum.SlashDash) { grid.Attributes.Line.Type = LineTypes.SlashDash; } else if (lineType == LineTypeEnum.SlashedLine) { grid.Attributes.Line.Type = LineTypes.SlashedLine; } else if (lineType == LineTypeEnum.SolidLine) { grid.Attributes.Line.Type = LineTypes.SolidLine; } else if (lineType == LineTypeEnum.UndefinedLine) { grid.Attributes.Line.Type = LineTypes.UndefinedLine; } } if (label == "OffsetAtEndOfLine") { grid.Attributes.OffsetAtEndOfLine = double.Parse(offsetAtEndOfLine); } if (label == "OffsetAtStartOfLine") { grid.Attributes.OffsetAtStartOfLine = double.Parse(offsetAtStartOfLine); } grid.Modify(); drawing.CommitChanges(); } } }
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 { } }