示例#1
0
        /*2016.6.21        /// <summary>
                /// ModAtrMD5() - calculate MD5 of the model read from Tekla in ModAtr
                /// </summary>
                /// <remarks>It could take few minutes for the large model</remarks>
                public static string ModAtrMD5()
                {
                    //            DateTime t0 = DateTime.Now;  
                    string str = "";
                    foreach (var att in ModAtr) str += att.mat + att.prf + att.lng.ToString();
                    ModelMD5 = Lib.ComputeMD5(str);
                    return ModelMD5;
                    //            new Log("MD5 time = " + (DateTime.Now - t0).ToString());
                } // ModAtrMD5
        2016.6.21 */
        public static string GetTeklaDir(ModelDir mode)
        {
            string TSdir = "";
            switch (mode)
            {
                case ModelDir.exceldesign:
// 6/4/17                    TeklaStructuresSettings.GetAdvancedOption("XS_EXTERNAL_EXCEL_DESIGN_PATH", ref TSdir);
                    TSdir = "C:\\ProgramData\\Tekla Structures\\2016i\\\\environments\\common\\exceldesign\\";
                    break;
                case ModelDir.model:
                    TSM.Model model = new TSM.Model();
                    ModInfo = model.GetInfo();
                    TSdir = ModInfo.ModelPath;
                    break;
                case ModelDir.macro:
                    TeklaStructuresSettings.GetAdvancedOption("XS_MACRO_DIRECTORY", ref TSdir);
                    string[] str = TSdir.Split(';');
                    TSdir = str[0] + @"\modeling";     // this Split is to ignore other, than common TS Enviroments
                    break;
                case ModelDir.environment:
                    TSdir = GetTeklaDir(ModelDir.exceldesign);
                    TSdir = Path.Combine(TSdir, @"..\..");
                    TSdir = Path.GetFullPath(TSdir);
                    break;
            }
            //////////            var ff = TeklaStructuresInfo.GetCurrentProgramVersion();
            //////////            var dd = TeklaStructuresFiles.GetAttributeFile(TSdir);
            //////////            TSdir = TS.TeklaStructuresFiles();
            return TSdir;
        }
        /// <summary>
        /// Connects the model interface.
        /// </summary>
        /// <returns>A boolean value indicating whether the interface is connected.</returns>
        public bool Connect()
        {
            try
            {
                if (this.connection == null)
                {
                    this.connection = new TSModelConnection();
                }

                if (this.events == null)
                {
                    this.events = new TSModelEvents();

                    this.RegisterEvents();
                }

                if (this.Localization == null)
                {
                    throw new NotSupportedException("Localization is not available.");
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);

                this.Disconnect();
            }

            return(this.IsActive);
        }
示例#3
0
        public MainPlugin(StructureData data)
        {
            TSM.Model Model = new TSM.Model();
            Data = data;

            GetValuesFromDialog();
        }
示例#4
0
        /// <summary>
        /// IsTeklaActice() - return true if TeklaStructures Process exists in Windows, and model is available 
        /// </summary>
        /// <returns>true if Tekla is up and running</returns>
        public static bool isTeklaActive()
        {
            Log.set("isTeklaActive()");
            bool ok = false;
            const string Tekla = "TeklaStructures";
            foreach (Process clsProcess in Process.GetProcesses())
            {
                if (clsProcess.ProcessName.ToLower().Contains(Tekla.ToLower()))
                {
                    TSM.Model model = new TSM.Model();
                    if (!model.GetConnectionStatus()) goto error;
                    try
                    {
                        ModInfo = model.GetInfo();
                        ok = model.GetConnectionStatus() && ModInfo.ModelName != "";
                    }
                    catch { goto error; }
                    break;
                }
            }
            Log.exit();
            return ok;

            error: throw new Exception("isTeklaActive no model Connection");
        }
        private void CreateNotConceptualFilterFile()
        {
            var filterText = @"TITLE_OBJECT_GROUP 
{
    Version= 1.05 
    Count= 1 
    SECTION_OBJECT_GROUP 
    {
        0 
        1 
        co_component 
        proIsConceptual 
        albl_Is_conceptual 
        == 
        albl_Equals 
        albl_No 
        0 
        && 
        }
    }
";

            var modelPath      = new TSM.Model().GetInfo().ModelPath;
            var attributesPath = System.IO.Path.Combine(modelPath, "attributes");
            var filePath       = System.IO.Path.Combine(attributesPath, "_isNotConceptual__.SObjGrp");

            File.WriteAllText(filePath, filterText);
        }
示例#6
0
        //Main method of the plug-in.
        public override bool Run(List <InputDefinition> Input)
        {
            try
            {
                GetValuesFromDialog();

                Point Point1       = (Point)(Input[0]).GetInput();
                Point Point2       = (Point)(Input[1]).GetInput();
                Point LengthVector = new Point(Point2.X - Point1.X, Point2.Y - Point1.Y, Point2.Z - Point1.Z);

                if (_LengthFactor > 0)
                {
                    Point2.X = _LengthFactor * LengthVector.X + Point1.X;
                    Point2.Y = _LengthFactor * LengthVector.Y + Point1.Y;
                    Point2.Z = _LengthFactor * LengthVector.Z + Point1.Z;
                }

                var identifier = (Identifier)Input[2].GetInput();
                var part       = new TSM.Model().SelectModelObject(identifier) as TSM.Part;

                CreateBeam(Point1, Point2, part?.Profile.ProfileString);
            }
            catch (Exception Ex)
            {
            }

            return(true);
        }
示例#7
0
        public override bool Run(List <InputDefinition> input)
        {
            try
            {
                Tekla.Structures.Identifier  id    = (Tekla.Structures.Identifier)(input[0]).GetInput();
                Tekla.Structures.Model.Model model = new TSM.Model();
                TSM.Beam beam = (TSM.Beam)model.SelectModelObject(id);

                model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TSM.TransformationPlane());
                TSM.TransformationPlane currentTP       = model.GetWorkPlaneHandler().GetCurrentTransformationPlane();
                CoordinateSystem        coordenadasMuro = beam.GetCoordinateSystem();
                model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TSM.TransformationPlane(coordenadasMuro));

                ParametrosPanel p = new ParametrosPanel(beam);
                p.dx                 = data.dx;
                p.dy                 = data.dy;
                p.diametroBarras     = data.diametroBarras;
                p.diametroDiagonal   = data.diametroDiagonales;
                p.adicionalDerecha   = data.largoDerecha;
                p.adicionalIzquierda = data.largoIzquierda;
                p.adicionalSuperior  = data.largoSuperior;
                p.adicionalInferior  = data.largoInferior;

                PanelMoldar panel = new PanelMoldar(p);
                panel.fabricar();

                model.GetWorkPlaneHandler().SetCurrentTransformationPlane(currentTP);
            }
            catch (Exception ex)
            {
                ErrorDialog.Show("Exception", ex.Message, ErrorDialog.Severity.ERROR);
            }

            return(true);
        }
示例#8
0
        private void ApplyConnection(ObservableCollection <ConnectionSetting> collection, string component, string boltweldtype, string angletype)
        {
            if (collection.Count == 0 || collection == null)
            {
                return;
            }
            var model     = new Tekla.Structures.Model.Model();
            var modelname = model.GetInfo().ModelName;
            var jobcode   = GetJobCodeOnProjectName(modelname);


            foreach (var item in collection)
            {
                if (item.IsChecked)
                {
                    var EnumComponent    = (int)Enum.Parse(typeof(ComponentType), component);
                    var EnumBoltweldtype = (int)Enum.Parse(typeof(BoltWeldOrientation), boltweldtype);
                    var EnumAngletype    = (int)Enum.Parse(typeof(AngleTypes), angletype);

                    ConnectionChecker cnc = new ConnectionChecker();
                    if (item.IsSingleConnection)
                    {
                        cnc.CreateConnection((Beam)item.PrimaryObject, (Beam)item.SecondaryObject, EnumComponent, jobcode, EnumBoltweldtype, EnumAngletype);
                    }
                    if (!item.IsSingleConnection)
                    {
                        cnc.CreateConnection((Beam)item.PrimaryObject, item.SecondaryObjects, EnumComponent, jobcode, EnumBoltweldtype, EnumAngletype);
                    }
                }
            }

            model.CommitChanges();
        }
 internal static TSM.ModelObject SelectModelObject(int objectId)
 {
     TSM.ModelObject result      = null;
     TSM.ModelObject modelObject =
         new TSM.Model().SelectModelObject(new Identifier(objectId));
     result = modelObject;
     return(result);
 }
示例#10
0
 /// <summary>
 /// Chained constructor for AngleBolts class
 /// </summary>
 /// <param name="boltModel"></param>
 /// <param name="boltSize"></param>
 /// <param name="boltQuantity"></param>
 /// <param name="boltStandard"></param>
 /// <param name="cutLength"></param>
 public AngleBolts(TSM.Model boltModel, double boltSize, int boltQuantity, string boltStandard, double cutLength)
 {
     // Assign values to fields of base class
     base.boltModel = boltModel;
     base.SetBoltSize(boltSize);
     base.SetBoltQuantity(boltQuantity);
     base.SetBoltStandard(boltStandard);
     base.SetCutLength(cutLength);
 }
示例#11
0
        public static string getModInfo()
        {
            string result = string.Empty;
            TSM.Model model = new TSM.Model();
            ModInfo = model.GetInfo();
            result = Path.GetFileNameWithoutExtension(ModInfo.ModelName);
//            if (!isTeklaModel(result)) Msg.F("TS_Open API getModInfo error");
            return result;
        }
 public TemporaryWorkplane(TSM.TransformationPlane planeToWorkOn)
 {
     _model = new TSM.Model();
     // save current plan
     _oldPlan = _model.GetWorkPlaneHandler().GetCurrentTransformationPlane();
     // set workplan
     _model.GetWorkPlaneHandler().SetCurrentTransformationPlane(planeToWorkOn);
     Tracer._trace("Setting new plane to work at.");
 }
示例#13
0
 private string getPhaseNameFromReinforcement(ReinforcementBase drawingObject)
 {
     TSDrg.ReinforcementBase dwgRebar = drawingObject as TSDrg.ReinforcementBase;
     TSM.Model       MyModel          = new TSM.Model();
     TSM.ModelObject modelRebar       = MyModel.SelectModelObject(dwgRebar.ModelIdentifier);
     TSM.Phase       rebarPhase       = new TSM.Phase();
     modelRebar.GetPhase(out rebarPhase);
     return(rebarPhase.PhaseName);
 }
        public static void Run(Tekla.Technology.Akit.IScript akit)
        {
            List <string> ignoreClasses = new List <string>();

            //ignoreClasses.Add("152");

            TSM.Model myModel = new TSM.Model();
            AssemblyToSubAssembly.main(ignoreClasses, akit);
            myModel.CommitChanges();
        }
示例#15
0
        public Form1()
        {
            InitializeComponent();
            InitializeForm();

            this.model = new TSM.Model();

            if (!this.model.GetConnectionStatus())
            {
                MessageBox.Show("Tekla is not running");
            }
        }
 public MainModel()
 {
     myModel = new Tekla.Structures.Model.Model();
     if (myModel.GetConnectionStatus())
     {
         phaseCollection = myModel.GetPhases();
         PhaseItemsList.CollectionChanged += PhaseItemsList_CollectionChanged;
     }
     else
     {
         MessageBox.Show("Tekla Structures might not be open. Please run Tekla and restart RebarPhaseManager.");
     }
 }
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         // set back old one
         if (null != _oldPlan)
         {
             Tracer._trace("Setting work plane back.");
             _model?.GetWorkPlaneHandler().SetCurrentTransformationPlane(_oldPlan);
         }
         _model = null; _oldPlan = null;
     }
 }
示例#18
0
 private bool InitializeConnection()
 {
     TSM.Model _model = new TSM.Model(); //Создаем переменную локальной модели.
     if (_model.GetConnectionStatus())   //Проверка подключения.
     {
         model = _model;                 // Передаем локальную модель, глобальной.
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#19
0
        private void btn_action_Click(object sender, EventArgs e)
        {
            // kết nối với model đang hiện hành.
            tsm.Model model = new tsm.Model();
            if (!model.GetConnectionStatus())
            {
                MessageBox.Show("Tekla is not connected!! @@");
                return;
            }
            // kiểm tra xem đã kết nối được với model chưa.
            //--------------------------------
            // Nhặt 2 đối tượng Rebar group
            tsm.RebarGroup rebargroup0 = null;
            tsm.RebarGroup rebargroup1 = null;
            // Khởi tạo picker
            mui.Picker picker = new mui.Picker();
            string     mess   = "";

            while (rebargroup0 == null & rebargroup1 == null)
            {
                try
                {
                    tsm.ModelObject obj0 = picker.PickObject(mui.Picker.PickObjectEnum.PICK_ONE_OBJECT, mess + "pick a group Rebar 0");
                    if (obj0 as tsm.RebarGroup != null)
                    {
                        rebargroup0 = obj0 as tsm.RebarGroup;
                        mess        = "";
                    }
                    else
                    {
                        mess = "Object is not a Rebar group. ";
                    }
                    tsm.ModelObject obj1 = picker.PickObject(mui.Picker.PickObjectEnum.PICK_ONE_OBJECT, mess + "pick a group Rebar 1");
                    if (obj1 as tsm.RebarGroup != null)
                    {
                        rebargroup1 = obj1 as tsm.RebarGroup;
                        mess        = "";
                    }
                    else
                    {
                        mess = "Object is not a Rebar group. ";
                    }
                }
                catch
                {
                    Operation.DisplayPrompt("not select");
                    return;
                }
            }
        }
示例#20
0
        private List <string> readBarInformation(ReinforcementBase dwgRebar)
        {
            List <string> info = new List <string>();

            TSM.Model       MyModel    = new TSM.Model();
            TSM.ModelObject modelRebar = MyModel.SelectModelObject(dwgRebar.ModelIdentifier);
            TSM.Phase       rebarPhase = new TSM.Phase();
            modelRebar.GetPhase(out rebarPhase);
            info.Add(rebarPhase.PhaseName);
            string shapeCode   = null;
            bool   gotProperty = modelRebar.GetReportProperty("REBAR_POS", ref shapeCode);

            info.Add(shapeCode);
            return(info);
        }
示例#21
0
        public static bool CreateBeam()
        {
            TSM.Model myModel = new TSM.Model();
            TSM.Beam  myBeam  = new TSM.Beam(new TSG3d.Point(1000, 1000, 1000),
                                             new TSG3d.Point(6000, 6000, 1000));
            myBeam.Material.MaterialString = "Concrete_Undefined";
            myBeam.Profile.ProfileString   = "800*400";
            bool creationResult = false;

            if (myBeam.Insert())
            {
                creationResult = myModel.CommitChanges();
            }
            return(creationResult);
        }
        public static bool main(TSD.Drawing drawing)
        {
            bool drawingStatus = true;

            TSM.Model _myModel = new TSM.Model();

            if (drawing is TSD.GADrawing)
            {
                drawingStatus = checkDrawing(UserSettings_UDA._GA_drawingProperties, drawing as TSD.GADrawing);
            }
            else if (drawing is TSD.CastUnitDrawing)
            {
                TSD.CastUnitDrawing cu = drawing as TSD.CastUnitDrawing;
                TSM.Assembly        currentAssembly = _myModel.SelectModelObject(cu.CastUnitIdentifier) as TSM.Assembly;
                TSM.Part            currentMainPart = currentAssembly.GetMainPart() as TSM.Part;

                drawingStatus = checkDrawing(UserSettings_UDA._CU_drawingProperties, cu);
                if (drawingStatus)
                {
                    drawingStatus = checkPart(UserSettings_UDA._CU_partProperties, currentMainPart, cu);
                }
            }
            else if (drawing is TSD.AssemblyDrawing)
            {
                TSD.AssemblyDrawing asd             = drawing as TSD.AssemblyDrawing;
                TSM.Assembly        currentAssembly = _myModel.SelectModelObject(asd.AssemblyIdentifier) as TSM.Assembly;
                TSM.Part            currentMainPart = currentAssembly.GetMainPart() as TSM.Part;

                drawingStatus = checkDrawing(UserSettings_UDA._A_drawingProperties, asd);
                if (drawingStatus)
                {
                    drawingStatus = checkPart(UserSettings_UDA._A_partProperties, currentMainPart, asd);
                }
            }
            else if (drawing is TSD.SinglePartDrawing)
            {
                TSD.SinglePartDrawing sp = drawing as TSD.SinglePartDrawing;
                TSM.Part currentPart     = _myModel.SelectModelObject(sp.PartIdentifier) as TSM.Part;

                drawingStatus = checkDrawing(UserSettings_UDA._SP_drawingProperties, sp);
                if (drawingStatus)
                {
                    drawingStatus = checkPart(UserSettings_UDA._SP_partProperties, currentPart, sp);
                }
            }

            return(drawingStatus);
        }
示例#23
0
 /// <summary>
 /// isTeklaModel(name) -- check if Tekla open with the model name
 /// </summary>
 /// <param name="name"></param>
 /// <returns>true if in Tekla active and open model == name</returns>
 /// <history>5.6.2016</history>
 public static bool isTeklaModel(string name)
 {
     Log.set("TS_OpenAPI.isTeklaModel(\"" + name + "\")");
     bool ok = false;
     if (isTeklaActive())
     {
         TSM.Model model = new TSM.Model();
         ModInfo = model.GetInfo();
         name = Path.GetFileNameWithoutExtension(name);
         //                ModInfo.ModelName = ModInfo.ModelName.Replace(".db1", "");
         string inTS = Path.GetFileNameWithoutExtension(ModInfo.ModelName);
         ok = Path.GetFileNameWithoutExtension(ModInfo.ModelName) == name;
     }
     Log.exit();
     return ok;
 }
示例#24
0
        public ConcreteColumnPlugin(StructuresData data)
        {
            Data         = data;
            _pluginModel = new TSM.Model();

            _columnProfile      = data.ColumnProfile;
            _rebarSize          = data.RebarSize;
            _rebarGrade         = data.RebarGrade;
            _rebarBendingRadius = data.RebarBendingRadius;

            if (!Double.TryParse(data.FootingSize, out _footingSize))
            {
                _footingSize = 100 * 25.4;
            }

            _footingProfile = Convert.ToString(_footingSize) + "*" + Convert.ToString(_footingSize);
        }
 /// <summary>
 /// Disconnects the model interface.
 /// </summary>
 public void Disconnect()
 {
     try
     {
         this.UnregisterEvents();
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex);
     }
     finally
     {
         this.events       = null;
         this.connection   = null;
         this.localization = null;
     }
 }
        public static List <Point> GetColumnPoints(
            Tekla.Structures.Model.Model Model,
            Point ptStart,
            Point ptEnd,
            double firstLevel,
            double secondLevel)
        {
            Vector vector1 = new Vector(ptEnd - ptStart);
            Vector vector2 = vector1.GetNormal() * firstLevel;
            Vector vector3 = vector1.GetNormal() * secondLevel;

            return(new List <Point>()
            {
                ptStart + (Point)vector2,
                ptStart + (Point)vector3
            });
        }
        public static List <Point> GetColumnPoints(
            Tekla.Structures.Model.Model Model,
            Point ptStart,
            double firstLevel,
            double secondLevel)
        {
            TransformationPlane transformationPlane = Model.GetWorkPlaneHandler().GetCurrentTransformationPlane();
            Matrix transformationMatrixToLocal      = transformationPlane.TransformationMatrixToLocal;
            Point  point   = transformationPlane.TransformationMatrixToGlobal.Transform(ptStart);
            Vector vector1 = new Vector(0.0, 0.0, firstLevel);
            Vector vector2 = new Vector(0.0, 0.0, secondLevel);

            point.Z = 0.0;
            Point p1 = point + (Point)vector1;
            Point p2 = point + (Point)vector2;

            return(new List <Point>()
            {
                transformationMatrixToLocal.Transform(p1),
                transformationMatrixToLocal.Transform(p2)
            });
        }
示例#28
0
        private string CheckPart(int objectId)
        {
            string str = "UNKNOWN";

            try
            {
                if (this.model == null)
                {
                    this.model = new Tekla.Structures.Model.Model();
                }
                BoltGroup boltGroup = this.model.SelectModelObject(new Identifier(objectId)) as BoltGroup;
                if (boltGroup == null)
                {
                    return(str);
                }
                return(this.SeparateBolt(boltGroup));
            }
            catch (Exception ex)
            {
                return(str);
            }
        }
示例#29
0
 public override bool Run(List <InputDefinition> Input)
 {
     try
     {
         GetvaluesFormDialog();
         Point point1   = (Point)(Input[0]).GetInput();
         Point point2   = (Point)(Input[1]).GetInput();
         Point lengthvt = new Point(point2.X - point1.X, point2.Y - point1.Y, point2.Z - point1.Z);
         if (_Lenght > 0)
         {
             point2.X = _Lenght * lengthvt.X + point1.X;
             point2.Y = _Lenght * lengthvt.Y + point1.Y;
             point2.Z = _Lenght * lengthvt.Z + point1.Z;
         }
         var identifien = (Identifier)Input[2].GetInput();
         var part       = new tsm.Model().SelectModelObject(identifien) as tsm.Part;
         CreatBeams(point1, point2, _Profile);
     }
     catch (Exception)
     {
     }
     return(true);
 }
        public static void Run(Tekla.Technology.Akit.IScript akit)
        {
            List<string> ignoreClasses = new List<string>();
            //ignoreClasses.Add("152");

            TSM.Model myModel = new TSM.Model();
            AssemblyToSubAssembly.main(ignoreClasses, akit);
            myModel.CommitChanges();
        }
        // This application assumes that users have already opened a drawing - an assembly drawing.
        // The goal is for the user to see that particular assembly
        // in the model, and to see ONLY that assembly in the model.
        // Therefore all parts which are not associated with this assembly need to be hidden.
        // All the clutter needs to be removed from view.
        // And all parts associated with this assembly need to be visible.
        // Summary: our goals is for users to see, given the particular assembly drawing that they are in,
        // just that ONE assembly within the model, and to have all other parts hidden.
        // Methodology:
        // 1. We obtain the assembly drawing and go through all the drawing objects within the assembly drawing. We get the identifiers of these
        ////  drawing objects and place them in a list (assemblyPartIdentifierList)
        // 2. We obtain the identifiers of all the objects in the model and place them on this list too.
        ///3. We want to hide all objects which are not associated with the assembly drawing which is currently open.
        ///4. Consequently, we obtain a List of identifiers which contains all the objects in the model APART from the assembly parts of the current assembly
        ///// we are working on.
        ///5. We convert this list of identifiers into a TSM.Model Object list, and then again convert this list into an ArrayList.
        ///6. The array list should contain all the objects we need to hide.
        ///7. We use the array list to select all the objects which need to be hidden, in the model.
        ///8. We want to call a macro which hides all the objects currently selected.
        // Two questions, (1) is the above approach a good and efficient wa to solve the above problem>
        // Given a drawing is open, how can one call a macro which hides all selected objects?
        // Your comemnts and criticism would be very much apprieciated.
        private void GetAssembly()
        {
            try
            {
            // creates model and drawing handle

                TSM.Model myModel = new TSM.Model();

                TSD.DrawingHandler dh = new TSD.DrawingHandler();

                if (dh.GetConnectionStatus() == false)
                {
                     System.Windows.Forms.MessageBox.Show("Could not connect drawing handler.");
                     return;
                }

            // users must have an Assembly drawing open. We want to see the assembly contained in the assembly drawing in the
            // UI. Hence we first obtain the identifiers of the drawing objects.

                TSD.Drawing currentDrawing = dh.GetActiveDrawing();

                if (currentDrawing == null)
                {
                    System.Windows.Forms.MessageBox.Show("Please ensure that an assembly drawing is open");
                    return;
                }

                TSD.AssemblyDrawing currentAssemblyDrawing = currentDrawing as TSD.AssemblyDrawing;

                if (currentAssemblyDrawing == null)
                {
                    System.Windows.Forms.MessageBox.Show("Please ensure that an assembly drawing is open");
                    return;
                }

                if (currentAssemblyDrawing != null)
                {
                    // in order to select in the model space we need to create an array list

                    ArrayList assemblyObjectToBeViewed = new ArrayList();

                    // we need to add a model object to the array list. We are adding the assembly as the model object for the model object selector to select
                    assemblyObjectToBeViewed.Add( myModel.SelectModelObject(currentAssemblyDrawing.AssemblyIdentifier) );

                    TSM.UI.ModelObjectSelector selector = new TSM.UI.ModelObjectSelector();
                    selector.Select(assemblyObjectToBeViewed);

                    TSM.Operations.Operation.RunMacro("ShowOnlySelected.cs");
                    TSM.Operations.Operation.RunMacro("FitToView.cs");
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("Please ensure you have an Assembly drawing open");
                }

            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
        }
示例#32
-1
        private void markHandler(TSD.Mark currentMark)
        {
            if (currentMark.Attributes.Content.Count > 0)
            {
                System.Type[] Types = new System.Type[1];
                Types.SetValue(typeof(TSD.ModelObject), 0);
                TSD.DrawingObjectEnumerator markObjects = currentMark.GetRelatedObjects(Types);

                foreach (TSD.ModelObject currentDO in markObjects)
                {
                    TSM.Model       myModel     = new TSM.Model();
                    TSM.ModelObject modelObject = myModel.SelectModelObject(currentDO.ModelIdentifier);

                    if (modelObject != null)
                    {
                        if (modelObject is TSM.Beam)
                        {
                            TSM.Beam currentMO = modelObject as TSM.Beam;
                            markBeams.Add(new _Mark_Beam(currentMark, currentMO, currentDO, this.view));
                        }
                        else if (modelObject is TSM.PolyBeam)
                        {
                            TSM.PolyBeam currentMO = modelObject as TSM.PolyBeam;
                            markPolyBeams.Add(new _Mark_PolyBeam(currentMark, currentMO, currentDO, this.view));
                        }
                        else if (modelObject is TSM.ContourPlate)
                        {
                            TSM.ContourPlate currentMO = modelObject as TSM.ContourPlate;
                            markContourPlates.Add(new _Mark_ContourPlate(currentMark, currentMO, currentDO, this.view));
                        }
                        else if (modelObject is TSM.SingleRebar)
                        {
                            TSM.SingleRebar currentMO = modelObject as TSM.SingleRebar;
                            markSingleRebars.Add(new _Mark_SingleRebar(currentMark, currentMO, currentDO, this.view));
                        }
                        else if (modelObject is TSM.RebarGroup)
                        {
                            TSM.BaseRebarGroup currentMO = modelObject as TSM.RebarGroup;
                            markRebarBases.Add(new _Mark_RebarGroup(currentMark, currentMO, currentDO, this.view));
                        }
                        else if (modelObject is TSM.BoltGroup)
                        {
                            TSM.BoltGroup currentMO = modelObject as TSM.BoltGroup;
                            markBoltGroup.Add(new _Mark_BoltGroup(currentMark, currentMO, currentDO, this.view));
                        }
                    }
                }
            }
        }