Beispiel #1
0
        private void AddView(string Name, TSD.Drawing MyDrawing, ArrayList Parts, TSG.CoordinateSystem coordinateSystem)
        {
            TSD.View MyView = new TSD.View(MyDrawing.GetSheet(), coordinateSystem, coordinateSystem, Parts);

            MyView.Name = Name;
            MyView.Insert();
        }
        /// <summary>Opens a drawing in the drawing editor.</summary>
        /// <param name="drawing">Drawing to open.</param>
        /// <returns>A boolean value indicating whether the drawing was opened.</returns>
        public bool Open(TSDrawing drawing)
        {
            if (this.IsActive)
            {
                return(SeparateThread.Execute <bool>(delegate { return this.connection.SetActiveDrawing(drawing, true); }));
            }

            return(false);
        }
        public static void main(TSD.Drawing drawing, ref bool globalCheckOK)
        {
            bool localCheckOK = true;



            if (localCheckOK == false)
            {
                globalCheckOK = false;
            }
        }
        public static bool checkPart(List <string> properties, TSM.Part part, TSD.Drawing drawing)
        {
            foreach (string prop in properties)
            {
                bool result = checkProperty(prop, part, drawing);
                if (result == false)
                {
                    return(false);
                }
            }

            return(true);
        }
        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);
        }
Beispiel #6
0
        private void AddRotatedView(string Name, TSD.Drawing MyDraiwng, ArrayList Parts, TSG.CoordinateSystem coordinateSystem)
        {
            TSG.CoordinateSystem displayCoordinateSystem = new TSG.CoordinateSystem();

            TSG.Matrix RotationAroundX = TSG.MatrixFactory.Rotate(20.0 * Math.PI * 2.0 / 360.0, coordinateSystem.AxisX);
            TSG.Matrix RotationAroundZ = TSG.MatrixFactory.Rotate(30.0 * Math.PI * 2.0 / 360.0, coordinateSystem.AxisY);

            TSG.Matrix Rotation = RotationAroundX * RotationAroundZ;

            displayCoordinateSystem.AxisX = new TSG.Vector(Rotation.Transform(new TSG.Point(coordinateSystem.AxisX)));
            displayCoordinateSystem.AxisY = new TSG.Vector(Rotation.Transform(new TSG.Point(coordinateSystem.AxisY)));

            TSD.View FrontView = new TSD.View(MyDraiwng.GetSheet(), coordinateSystem, displayCoordinateSystem, Parts);

            FrontView.Name = Name;
            FrontView.Insert();
        }
        public static void main(TSD.Drawing drawing)
        {
            string printerName = selectPrinter(drawing);

            if (printerName == "NOT FOUND")
            {
                throw new DivideByZeroException();
            }

            new TeklaMacroBuilder.MacroBuilder()
            .Callback("acmd_display_plot_dialog", "", "main_frame")
            .ValueChange("Plot", "add_revision_info_to_filename", UserSettings_PDF.add_revision_info_to_filename)     //Include Revision Mark
            .ListSelect("Plot", "component_list", printerName)
            .PushButton("butPrint", "Plot")
            .PushButton("cancel_pb", "Plot")
            .Run();
        }
Beispiel #8
0
        public static void main(TSD.Drawing drawing)
        {
            TSD.DrawingHandler drawingHandler = new TSD.DrawingHandler();
            drawingHandler.SetActiveDrawing(drawing, true);

            bool printingStatus = true;

            if (UserSettings_GLOBAL._removeClouds)
            {
                RemoveClouds.main();
            }

            if (UserControls._pdf)
            {
                try
                {
                    ExportPDF.main(drawing);
                }
                catch
                {
                    printingStatus = false;
                    MainWindow._form.consoleOutput("[ERROR - 4] Failed printing!", "L2");
                }
            }

            if (UserControls._dwg)
            {
                try
                {
                    ExportDWG.main(drawing);
                }
                catch
                {
                    printingStatus = false;
                    MainWindow._form.consoleOutput("[ERROR - 5] Failed exporting!", "L2");
                }
            }

            drawingHandler.CloseActiveDrawing(UserSettings_GLOBAL._drawingSave);

            if (printingStatus == false)
            {
                throw new DivideByZeroException();
            }
        }
        public static string selectPrinter(TSD.Drawing drawing)
        {
            string plotter = "NOT FOUND";

            int height = Convert.ToInt32(drawing.Layout.SheetSize.Height);
            int width  = Convert.ToInt32(drawing.Layout.SheetSize.Width);

            foreach (PaperSize current in UserSettings_PDF._plotters)
            {
                if ((width % current._width == 0) && height == current._height)
                {
                    plotter = current._plotterName;
                }
            }

            MainWindow._form.consoleOutput("PRINT - " + plotter + " (" + width.ToString() + "x" + height.ToString() + ")", "L2");
            return(plotter);
        }
        public static void DateLastMark(TSD.Drawing croquis, out string revisionMark, out int revisionDateSeconds)
        {
            Type         drawingType  = croquis.GetType();
            PropertyInfo propertyInfo = drawingType.GetProperty("Identifier", BindingFlags.Instance | BindingFlags.NonPublic);
            object       value        = propertyInfo.GetValue(croquis, null);

            Identifier identifier = (Identifier)value;

            TSM.Beam fakeBeam = new TSM.Beam {
                Identifier = identifier
            };

            revisionMark = "";
            fakeBeam.GetReportProperty("REVISION.LAST_MARK", ref revisionMark);

            revisionDateSeconds = 0;
            fakeBeam.GetReportProperty("REVISION.LAST_DATE_CREATE", ref revisionDateSeconds);
        }
        public static bool checkProperty(string prop, TSD.Drawing drawing)
        {
            string dummy = "dummy";

            drawing.GetUserProperty(prop, ref dummy);

            int dummyInt = -987;

            drawing.GetUserProperty(prop, ref dummyInt);

            bool status = checker(dummy, dummyInt);

            if (status == false)
            {
                MainWindow._form.consoleOutput(drawing.Mark + " " + prop + " is not set", "L2");
            }

            return(status);
        }
Beispiel #12
0
 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);
         }
     }
 }
        public static double getHighestScale(TSD.Drawing currentDrawing)
        {
            double highestScale = 0;

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

            while (ViewEnum.MoveNext())
            {
                if (ViewEnum.Current is TSD.View)
                {
                    TSD.View currentView = ViewEnum.Current as TSD.View;

                    if (isView2D(currentView))
                    {
                        double currentScale = currentView.Attributes.Scale;
                        highestScale = Math.Max(currentScale, highestScale);
                    }
                }
            }

            MainWindow._form.consoleOutput("EXPORT - Scale: " + highestScale.ToString(), "L2");

            return(highestScale);
        }
        public static void main(TSD.Drawing drawing)
        {
            double scaleFactor   = getHighestScale(drawing);
            double lineTypeScale = scaleFactor;

            if (scaleFactor == 0)
            {
                throw new DivideByZeroException();
            }

            new TeklaMacroBuilder.MacroBuilder()
            .Callback("acmdDisplayExportDrawingsDialog", "", "main_frame")

            .ValueChange("diaExportDrawings", "textFileName", UserSettings_DWG.textFileName)             //Name
            .ValueChange("diaExportDrawings", "optMnuFileType", UserSettings_DWG.optMnuFileType)         //Type DWG
            .ValueChange("diaExportDrawings", "chkButRevisionMark", UserSettings_DWG.chkButRevisionMark) //Include Revision Mark

            //.TabChange("diaExportDrawings", "tabWndProperties", "tabLayerOptions")
            .ValueChange("diaExportDrawings", "optMnuLayerFile", UserSettings_DWG.optMnuLayerFile)                                 //Layer rules
            .ValueChange("diaExportDrawings", "chkUseAdvancedLineTypeConversio", UserSettings_DWG.chkUseAdvancedLineTypeConversio) //Use advanced line type and layer conversion
            .ValueChange("diaExportDrawings", "txtLineTypeMappingFile", UserSettings_DWG.txtLineTypeMappingFile)                   //Conversion type
            .ValueChange("diaExportDrawings", "chkButIncludeEmptyLayers", UserSettings_DWG.chkButIncludeEmptyLayers)               //Include empty layer
            .ValueChange("diaExportDrawings", "chkButObjectColorByLayer", UserSettings_DWG.chkButObjectColorByLayer)               //Object color by layer

            //.TabChange("diaExportDrawings", "tabWndProperties", "tabOptions")
            .ValueChange("diaExportDrawings", "textScaleFactor", scaleFactor.ToString())               //Drawing scale
            .ValueChange("diaExportDrawings", "txtLineTypeScale", lineTypeScale.ToString())            //Line type scale
            .ValueChange("diaExportDrawings", "chkUseGrouping", UserSettings_DWG.chkUseGrouping)       //Export objects as groups
            .ValueChange("diaExportDrawings", "chkUseLineCliping", UserSettings_DWG.chkUseLineCliping) //Cut lines with text
            .ValueChange("diaExportDrawings", "chkSplitSoftLines", UserSettings_DWG.chkSplitSoftLines) //Export custom lines as split lines
            .ValueChange("diaExportDrawings", "chkUsePaperSpace", UserSettings_DWG.chkUsePaperSpace)   //Use paper space

            .PushButton("butExport", "diaExportDrawings")
            .PushButton("butCancel", "diaExportDrawings")
            .Run();
        }
        public static void main(TSD.Drawing drawing)
        {
            StringBuilder csv = new StringBuilder();

            string name = drawing.Title1;
            string nr   = drawing.Name;

            int    dmtDateSeconds = 0;
            string dmtDateString  = "";

            drawing.GetUserProperty("DR_RESP_DSGNR_DATE", ref dmtDateSeconds);
            if (dmtDateSeconds != 0)
            {
                DateTime dmtDate = new DateTime(1970, 1, 1);
                dmtDate       = dmtDate.AddSeconds(dmtDateSeconds);
                dmtDateString = dmtDate.ToShortDateString();
            }

            int    revisionDateSeconds = 0;
            string revisionMark        = "";
            string revisionDateString  = "";

            DateLastMark(drawing, out revisionMark, out revisionDateSeconds);
            if (revisionDateSeconds != 0)
            {
                DateTime revisionDate = new DateTime(1970, 1, 1);
                revisionDate       = revisionDate.AddSeconds(revisionDateSeconds);
                revisionDateString = revisionDate.ToShortDateString();
            }

            string newLine = string.Format("{0};{1};{2};{3};{4};", name, nr, revisionMark, dmtDateString, revisionDateString);

            csv.AppendLine(newLine);

            addCSV(csv.ToString());
        }
        // 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 static 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);
            }
        }