Example #1
0
        public void STLInCommand()
        {
            Editor   editor   = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            Database arg_15_0 = HostApplicationServices.WorkingDatabase;

            try
            {
                //LicenseManager.CheckValid("FULL");
                CommandLineQuerries.SpecifyFileNameForRead(ref CMD_STL.string_3, "stl");
                string a = this.method_2(CMD_STL.string_3);
                if (a == "A")
                {
                    editor.WriteMessage("\nASCII STL format file identified.");
                    CMD_STL.string_0 = CommandLineQuerries.InsertOnLayer_Current_Name_STL(CMD_STL.string_0);
                    this.method_0(CMD_STL.string_3);
                }
                else if (a == "B")
                {
                    editor.WriteMessage("\nBinary STL format file identified.");
                    if (CMD_STL.string_0 == "S")
                    {
                        CMD_STL.string_0 = "C";
                    }
                    CMD_STL.string_0 = CommandLineQuerries.InsertOnLayer_Current_Name(CMD_STL.string_0);
                    this.method_1(CMD_STL.string_3);
                }
                DBManager.ZoomExtents();
            }
            catch (System.Exception ex)
            {
                editor.WriteMessage("\n" + ex.Message);
            }
        }
Example #2
0
 public void XYZIN()
 {
     try
     {
         ////LicenseManager.CheckValid("FULL");
         CommandLineQuerries.SpecifyFileNameForRead(ref IO2.string_4, "xyz");
         this.method_4();
     }
     catch (System.Exception ex)
     {
         Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
         editor.WriteMessage(Environment.NewLine + ex.Message + Environment.NewLine);
     }
 }
Example #3
0
        public void InstallLicenseCommand()
        {
            Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            try
            {
                CommandLineQuerries.SpecifyFileNameForRead(ref LicenseManager.string_0, "license");
                if (!File.Exists(LicenseManager.string_0))
                {
                    editor.WriteMessage("\n" + LicenseManager.string_0 + " does not exist.");
                }
                else
                {
                    Reg.SetComputationalCADRegistryValue("LICENSEFILE", LicenseManager.string_0);
                    LicenseManager.Initialize();
                }
            }
            catch (System.Exception ex)
            {
                editor.WriteMessage(Environment.NewLine + ex.Message + Environment.NewLine);
            }
        }
Example #4
0
        public void ReadOFFCommand()
        {
            Database workingDatabase = HostApplicationServices.WorkingDatabase;
            Editor   editor          = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            try
            {
                //LicenseManager.CheckValid("FULL");
                CommandLineQuerries.SpecifyFileNameForRead(ref OFF.string_0, "off");
                int                num   = 0;
                int                num2  = 0;
                List <Point>       list  = new List <Point>();
                List <List <int> > list2 = new List <List <int> >();
                using (StreamReader streamReader = new StreamReader(OFF.string_0))
                {
                    int num3 = 0;
                    int num4 = 0;
                    int num5 = 0;
                    while (streamReader.Peek() >= 0)
                    {
                        string text = streamReader.ReadLine();
                        if (!text.StartsWith("#") && !(text.Trim() == ""))
                        {
                            string[] array = text.Split(new char[]
                            {
                                ' '
                            }, StringSplitOptions.RemoveEmptyEntries);
                            if (num3 == 0)
                            {
                                if (text.Trim().ToUpper() != "OFF")
                                {
                                    throw new System.Exception(".OFF file does not start with 'OFF'");
                                }
                            }
                            else if (num3 == 1)
                            {
                                num4 = Convert.ToInt32(array[0]);
                                num5 = Convert.ToInt32(array[1]);
                            }
                            else if (num3 < num4 + 2)
                            {
                                double x = Convert.ToDouble(array[0]);
                                double y = Convert.ToDouble(array[1]);
                                double z = Convert.ToDouble(array[2]);
                                list.Add(new Point(x, y, z));
                            }
                            else if (num3 < num4 + num5 + 2)
                            {
                                int        num6  = Convert.ToInt32(array[0]);
                                List <int> list3 = new List <int>();
                                for (int i = 0; i < num6; i++)
                                {
                                    list3.Add(Convert.ToInt32(array[i + 1]));
                                }
                                list2.Add(list3);
                            }
                            num3++;
                        }
                    }
                }
                using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction())
                {
                    BlockTable       blockTable       = (BlockTable)transaction.GetObject(workingDatabase.BlockTableId, (OpenMode)1);
                    BlockTableRecord blockTableRecord = (BlockTableRecord)transaction.GetObject(blockTable[BlockTableRecord.ModelSpace], (OpenMode)1);
                    for (int j = 0; j < list2.Count; j++)
                    {
                        try
                        {
                            Face acadFace = this.GetAcadFace(list2[j], list);
                            blockTableRecord.AppendEntity(acadFace);
                            transaction.AddNewlyCreatedDBObject(acadFace, true);
                            num2++;
                        }
                        catch (System.Exception ex)
                        {
                            num++;
                        }
                    }
                    transaction.Commit();
                }
                editor.WriteMessage("\nNumber of triangles read      : " + num2.ToString());
                editor.WriteMessage("\nNumber of degenerate triangles: " + num.ToString());
                DBManager.ZoomExtents();
            }
            catch (System.Exception ex)
            {
                editor.WriteMessage("\n" + ex.Message);
            }
        }