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();
                }
            }
        }
Exemple #2
0
        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 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();
                }
            }
        }
Exemple #4
0
        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 { }
        }
Exemple #5
0
        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 { }
        }
Exemple #6
0
        /// <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培训石头哥提示您标注结束,感谢您对智能标注系统的支持。");
        }
Exemple #7
0
        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 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 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();
                }
            }
        }
Exemple #10
0
 public static dynamic GetTSObject(DrawingObjectEnumerator dynObject)
 {
     if (dynObject is null)
     {
         return(null);
     }
     return(dynObject.teklaObject);
 }
Exemple #11
0
        /// <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();
            }
        }
        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    = "";
            }
        }
        /// <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 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");
        }
Exemple #16
0
        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());
            }
        }
Exemple #17
0
        internal static DrawingObjectEnumerator GetSelectedParts()
        {
            TSD.DrawingHandler      drawingHandler = new TSD.DrawingHandler();
            Drawing                 activeDrawing  = drawingHandler.GetActiveDrawing();
            ViewBase                sheet          = activeDrawing.GetSheet();
            DrawingObjectEnumerator objects        = sheet.GetAllObjects();

            objects.Reset();
            DrawingObjectSelector dos = drawingHandler.GetDrawingObjectSelector();

            objects = dos.GetSelected();
            return(objects);
        }
        /// <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);
        }
Exemple #19
0
        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 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);
        }
Exemple #22
0
        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();
                }
            }
        }
Exemple #24
0
        //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
                        }
                    }
                }
            }
        }
Exemple #25
0
        private static double getHighestScale(Drawing currentDrawing)
        {
            double highestScale = 0;

            DrawingObjectEnumerator ViewEnum = currentDrawing.GetSheet().GetViews();

            foreach (TSD.View currentView in ViewEnum)
            {
                if (isView2D(currentView))
                {
                    double currentScale = currentView.Attributes.Scale;
                    highestScale = Math.Max(currentScale, highestScale);
                }
            }

            return(highestScale);
        }
Exemple #26
0
        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();
                    }
                }
            }
        }
Exemple #27
0
        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();
            }
        }
Exemple #29
0
        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();
                    }
                }
            }
        }