Example #1
0
        /// <summary>
        /// Loading fileNames of user command files
        /// </summary>
        /// <returns>Collection of files</returns>
        private void LoadingULF()
        {
            // Write message to command window
            Autodesk.AutoCAD.EditorInput.Editor ed =
                Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.
                MdiActiveDocument.Editor;
            try
            {
                ed.WriteMessage("\nLoading ULF Database ...");

                // Get all userCommandFiles
                string[] ULFFiles;
                ULFFiles = eApp.EneCadRegistry.UserCommandFiles;
                foreach (string file in ULFFiles)
                {
                    string cont = System.IO.File.ReadAllText(file);
                    LoadingULF(cont);
                }
            }
            catch (System.Exception ex)
            {
                ed.WriteMessage(ex.Message);
                ed.WriteMessage("\nLoading ULF Database unsuccessfully!");
            }
        }
        //[CommandMethod("PrintAllPressurePipes")]
        //public void PrintAllPressurePipes()
        //{
        //    ObjectIdCollection pipeIds = PipeIdsCollection();
        //}

        public static ObjectIdCollection PipeIdsCollection()
        {
            ObjectIdCollection pipeIds    = new ObjectIdCollection();
            ObjectIdCollection networkIds = CivilDocumentPressurePipesExtension.GetPressurePipeNetworkIds(CivilApplication.ActiveDocument);

            Autodesk.AutoCAD.EditorInput.Editor m_deditor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            using (Transaction trans = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction())
            {
                foreach (ObjectId id in networkIds)
                {
                    PressurePipeNetwork networkObj = trans.GetObject(id, OpenMode.ForRead) as PressurePipeNetwork;
                    pipeIds = networkObj.GetPipeIds();
                    foreach (ObjectId pipeId in pipeIds)
                    {
                        // Test code
                        PressurePipe pipeObj = trans.GetObject(pipeId, OpenMode.ForRead) as PressurePipe;


                        m_deditor.WriteMessage("Pipe Name: {0}\n", pipeObj.Name);
                        m_deditor.WriteMessage("Pipe Material: {0}\n", pipeObj.PipeMaterial);
                        m_deditor.WriteMessage("Pipe InnerDiameter: {0}\n", pipeObj.InnerDiameter);
                        m_deditor.WriteMessage("Pipe Network Name: {0}\n", pipeObj.NetworkName);
                        // End test

                        //args.Add(PipeRuleSignature.PipeArgument.Name, pipeObj);
                        //args.Add(PipeRuleSignature.ResultArgument.Name, result);
                        //RuleManagerInstance.InvokeRulePoint("/PipeRule", args);
                    }
                }
            }

            return(pipeIds);
        }
Example #3
0
        public frmDesignProfile()
        {
            Autodesk.AutoCAD.EditorInput.Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            ed.WriteMessage("\nchecking.....\n");
            if (!Atend.Global.Acad.DrawEquips.Dicision.IsHere())
            {
                if (!Atend.Global.Acad.DrawEquips.Dicision.IsThere())
                {
                    //System.Diagnostics.Process[] prs = System.Diagnostics.Process.GetProcesses();
                    //foreach (System.Diagnostics.Process pr in prs)
                    //{
                    //    if (pr.ProcessName == "acad")
                    //    {
                    //        pr.CloseMainWindow();
                    //    }
                    //}
                    Atend.Global.Acad.Notification notification = new Atend.Global.Acad.Notification();
                    notification.Title = "شناسایی قفل";
                    notification.Msg   = "لطفا وضعیت قفل را بررسی نمایید ";
                    notification.infoCenterBalloon();

                    ForceToClose = true;
                }
            }
            InitializeComponent();
        }
Example #4
0
 /// <summary>
 /// Dumps the object to the console.
 /// </summary>
 /// <param name="obj"></param>
 public static void Dump(this object obj)
 {
     Autodesk.AutoCAD.ApplicationServices.Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
     Autodesk.AutoCAD.EditorInput.Editor           ed  = doc.Editor;
     foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(obj))
     {
         string name  = descriptor.Name;
         object value = descriptor.GetValue(obj);
         ed.WriteMessage("\n{0}={1}", name, value);
     }
 }
Example #5
0
 private static void UpdateTableWithValues(Autodesk.AutoCAD.EditorInput.Editor editor, Table table, Transaction tr, ColumnsCollection columns)
 {
     for (int i = 1; i < int.MaxValue; i++)
     {
         try
         {
             CommonMethods.FillPiket(editor, table, tr, i);
             ProcessSmallTable(editor, table, tr, columns, i);
         }
         catch (Exception)
         {
             editor.WriteMessage("Завершение программы. Дай Бог вам здоровья\n");
             break;
         }
     }
 }
Example #6
0
        static private void  SetOpacity()
        {
            Autodesk.AutoCAD.EditorInput.Editor e = AcadApp.DocumentManager.MdiActiveDocument.Editor;

            Autodesk.AutoCAD.EditorInput.PromptIntegerResult resInt;
            do
            {
                resInt = e.GetInteger("Enter opacity:");
                if (resInt.Status != Autodesk.AutoCAD.EditorInput.PromptStatus.OK)
                {
                    break;
                }
                if (resInt.Value >= 0 && resInt.Value <= 100)
                {
                    break;
                }
                e.WriteMessage("Opacity must be between 0 and 100\n");
            }while (true);

            ps.Opacity = resInt.Value;
        }
Example #7
0
        public static void DoIt()
        {
            if (ps == null)
            {
                //use constructor with Guid so that we can save/load user data
                ps       = new Autodesk.AutoCAD.Windows.PaletteSet("Test Palette Set", new Guid("63B8DB5B-10E4-4924-B8A2-A9CF9158E4F6"));
                ps.Load += new Autodesk.AutoCAD.Windows.PalettePersistEventHandler(ps_Load);
                ps.Save += new Autodesk.AutoCAD.Windows.PalettePersistEventHandler(ps_Save);
                ps.Style = Autodesk.AutoCAD.Windows.PaletteSetStyles.NameEditable |
                           Autodesk.AutoCAD.Windows.PaletteSetStyles.ShowPropertiesMenu |
                           Autodesk.AutoCAD.Windows.PaletteSetStyles.ShowAutoHideButton |
                           Autodesk.AutoCAD.Windows.PaletteSetStyles.ShowCloseButton;
                ps.MinimumSize = new System.Drawing.Size(300, 300);
                ps.Add("Test Palette 1", new TestControl());
            }
            bool b = ps.Visible;

            ps.Visible = true;
            Autodesk.AutoCAD.EditorInput.Editor e = AcadApp.DocumentManager.MdiActiveDocument.Editor;

            Autodesk.AutoCAD.EditorInput.PromptResult res = e.GetKeywords("Select a palette set option:", "Opacity", "TitleBarLocation", "Docking");
            if (res.Status == Autodesk.AutoCAD.EditorInput.PromptStatus.OK)
            {
                switch (res.StringResult)
                {
                case "Opacity":
                    Autodesk.AutoCAD.EditorInput.PromptIntegerResult resInt;
                    do
                    {
                        resInt = e.GetInteger("Enter opacity:");
                        if (resInt.Status != Autodesk.AutoCAD.EditorInput.PromptStatus.OK)
                        {
                            break;
                        }
                        if (resInt.Value >= 0 && resInt.Value <= 100)
                        {
                            break;
                        }
                        e.WriteMessage("Opacity must be between 0 and 100\n");
                    }while (true);
                    ps.Opacity = resInt.Value;
                    break;

                case "TitleBarLocation":
                    res = e.GetKeywords("Select titlebar location:", "Left", "Right");
                    if (res.Status == Autodesk.AutoCAD.EditorInput.PromptStatus.OK)
                    {
                        switch (res.StringResult)
                        {
                        case "Left":
                            ps.TitleBarLocation = Autodesk.AutoCAD.Windows.PaletteSetTitleBarLocation.Left;
                            break;

                        case "Right":
                            ps.TitleBarLocation = Autodesk.AutoCAD.Windows.PaletteSetTitleBarLocation.Right;
                            break;
                        }
                    }
                    break;

                case "Docking":
                {
                    res = e.GetKeywords("Choose a docking option:", "None", "Left", "Right", "Top", "Bottom");
                    if (res.Status == Autodesk.AutoCAD.EditorInput.PromptStatus.OK)
                    {
                        switch (res.StringResult)
                        {
                        case "None":
                            ps.Dock = Autodesk.AutoCAD.Windows.DockSides.None;
                            break;

                        case "Left":
                            ps.Dock = Autodesk.AutoCAD.Windows.DockSides.Left;
                            break;

                        case "Right":
                            ps.Dock = Autodesk.AutoCAD.Windows.DockSides.Right;
                            break;

                        case "Top":
                            ps.Dock = Autodesk.AutoCAD.Windows.DockSides.Top;
                            break;

                        case "Bottom":
                            ps.Dock = Autodesk.AutoCAD.Windows.DockSides.Bottom;
                            break;
                        }
                    }
                    break;
                }
                }
            }
        }
Example #8
0
        public static bool IsThere()
        {
            Autodesk.AutoCAD.EditorInput.Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            const ushort VALIDDATA_LENGTH          = 4;
            bool         Answer = false;

            //---- check terminal
            int allowCheck;

            allowCheck = Dicisionpro.SP_ALLOW_CHECK_TERMINAL_CLIENT;

            //if (TerminalClientCheck.Checked == true)
            if (true)
            {
                allowCheck = Dicisionpro.SP_ALLOW_CHECK_TERMINAL_CLIENT;
            }
            //ed.WriteMessage("  ##  ##  0 \n");
            //if (TerminalClientCheck.Checked == false)
            //{
            //    allowCheck = Dicisionpro.SP_DISALLOW_CHECK_TERMINAL_CLIENT;
            //}

            //----------------


            //------ set shered licence -----
            ushort shareMainLic, shareSubLic;

            //ushort status;
            shareMainLic = Dicisionpro.SP_DISABLE_MAINLIC_SHARING;
            shareSubLic  = Dicisionpro.SP_DISABLE_SUBLIC_SHARING;

            //-------------------------------

            if (DicisionNativeApi.RNBOsproFormatPacket(packet, Dicisionpro.SPRO_APIPACKET_SIZE) == 0)
            {
                //ed.WriteMessage("  ##  ##  1 \n");
                if (DicisionNativeApi.RNBOsproInitialize(packet) == 0)
                {
                    //ed.WriteMessage("  ##  ##  2 \n");
                    if (DicisionNativeApi.RNBOsproSetProtocol(packet, (int)Dicisionpro.PROTOCOL_FLAG.NSPRO_TCP_PROTOCOL) == 0)
                    {
                        //ed.WriteMessage("  ##  ##  3 \n");
                        status = RNBOsproCheckTerminalService(allowCheck);
                        //If API successfull
                        if (status == 0)
                        {
                            //ed.WriteMessage("  ##  ##  4 \n");
                            //Clear all the input text box
                            //clearTextBox_succ("CheckTerminalService");
                            string ServerName = Atend.Control.ConnectionString.LST;
                            if (DicisionNativeApi.RNBOsproSetContactServer(packet, ServerName) == 0)
                            {
                                //ed.WriteMessage("  ##  ##  5 \n");
                                string sDevID = "1c6d";// string variable for DevID
                                ushort DevID  = 0;
                                isValidData(sDevID.Trim(), VALIDDATA_LENGTH, ref DevID);
                                ushort result = DicisionNativeApi.RNBOsproFindFirstUnit(packet, DevID);
                                if (result == 0)
                                {
                                    //ed.WriteMessage("  ##  ##  6 \n");
                                    //if (MainSharing.Checked != false)
                                    //if (true)
                                    //{
                                    //if (MainSharing.Checked == true && SubLicSharing.Checked == true)
                                    //if (true && true)
                                    //{
                                    //    shareMainLic = Superpro.SP_ENABLE_MAINLIC_SHARING;
                                    //    shareSubLic = Superpro.SP_ENABLE_SUBLIC_SHARING;
                                    //}
                                    //if (MainSharing.Checked == true && SubLicSharing.Checked == false)
                                    //////////////////if (true)
                                    //////////////////{
                                    //////////////////    shareMainLic = Dicisionpro.SP_ENABLE_MAINLIC_SHARING;
                                    //////////////////    shareSubLic = Dicisionpro.SP_DISABLE_SUBLIC_SHARING;
                                    //////////////////}
                                    //}
                                    //**************RNBOsproSetSharedLicense API **********************
                                    //////////////////////status = RNBOsproSetSharedLicense(shareMainLic, shareSubLic);
                                    ////////////////////////If API successfull
                                    //////////////////////if (status == 0)
                                    //////////////////////{
                                    //Clear all the input text box
                                    //clearTextBox_succ("SetSharedLicense");

                                    ////////////sDevID = "1c6d";// string variable for DevID
                                    ////////////DevID = 0;
                                    ////////////isValidData(sDevID.Trim(), VALIDDATA_LENGTH, ref DevID);
                                    ////////////result = DicisionNativeApi.RNBOsproFindFirstUnit(packet, DevID);
                                    ////////////if (result == 0)
                                    ////////////{

                                    //ed.WriteMessage("THERE FOUND \n");
                                    Answer = true;
                                    ////////////}

                                    ////////////////////}
                                    ////////////////////else //If API failed then
                                    ////////////////////{
                                    ////////////////////    //Display API failure message with API return code.
                                    ////////////////////    //clearTextBox_fail("SetSharedLicense", status);
                                    ////////////////////    //RNBOsproSetSharedLicense
                                    ////////////////////    ed.WriteMessage("SuperproNativeApi.RNBOsproSetSharedLicense failed \n");
                                    ////////////////////}
                                }
                                else
                                {
                                    //RNBOsproFindFirstUnit
                                    ed.WriteMessage("SuperproNativeApi.RNBOsproFindFirstUnit failed \n");
                                }
                            }
                            else
                            {
                                ed.WriteMessage("SuperproNativeApi.RNBOsproSetContactServer failed \n");
                            }
                        }
                        else //If API failed then
                        {
                            //Display API failure message with API return code.
                            //clearTextBox_fail("CheckTerminalService", status);
                            ed.WriteMessage("DicisionNativeApi.RNBOsproCheckTerminalService failed \n");
                        }
                    }
                    else
                    {
                        ed.WriteMessage("DicisionNativeApi.RNBOsproSetProtocol failed \n");
                    }
                }
                else
                {
                    ed.WriteMessage("DicisionNativeApi.RNBOsproInitialize failed \n");
                }
            }
            else
            {
                ed.WriteMessage("DicisionNativeApi.RNBOsproFormatPacket failed \n");
            }
            return(Answer);
            //return true;
        }
Example #9
0
        /// <summary>
        /// Loading Enesy Command Method (ECM) information in this assembly
        /// </summary>
        /// <param name="markedOnly">Default value: false</param>
        internal void LoadingECM(bool markedOnly)
        {
            // Write message to command window
            Autodesk.AutoCAD.EditorInput.Editor ed =
                Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.
                MdiActiveDocument.Editor;
            ed.WriteMessage("\nLoading ECM Database ...");

            // Just get the commands for this assembly
            Assembly asm = Assembly.GetExecutingAssembly();

            // for command category
            object[] categorys = asm.GetCustomAttributes(typeof(CommandGroup), true);
            Type[]   catTypes;
            int      catNumtypes = categorys.Length;



            // Get EnesyCommandMethod attributes
            object[] objs = asm.GetCustomAttributes(typeof(EnesyCADCommandMethod), true);
            Type[]   tps;
            int      numTypes = objs.Length;

            if (numTypes > 0)
            {
                tps = new Type[numTypes];
                for (int i = 0; i < numTypes; i++)
                {
                    CommandClassAttribute cca = objs[i] as CommandClassAttribute;
                    if (cca != null)
                    {
                        tps[i] = cca.Type;
                    }
                }
            }
            else
            {
                // If we're only looking for specifically marked CommandClasses, then use an
                // empty list
                if (markedOnly)
                {
                    tps = new Type[0];
                }
                else
                {
                    tps = asm.GetExportedTypes();
                }
            }

            // Append valid value into Database
            foreach (Type tp in tps)
            {
                MethodInfo[] meths = tp.GetMethods();
                foreach (MethodInfo meth in meths)
                {
                    objs = meth.GetCustomAttributes(typeof(EnesyCADCommandMethod), true);
                    foreach (object obj in objs)
                    {
                        EnesyCADCommandMethod attb = (EnesyCADCommandMethod)obj;
                        if (!attb.IsTest)
                        {
                            // get command category
                            object[] cats     = meth.GetCustomAttributes(typeof(CommandGroup), true);
                            string   category = "";
                            int      index    = 0;
                            foreach (object c in cats)
                            {
                                index++;
                                CommandGroup commandCat = c as CommandGroup;
                                //GLOBAL.WriteMessage("Command " + attb.GlobalName + " - Category: " + commandCat.Category);
                                category = commandCat.Category;
                            }
                            //GLOBAL.WriteMessage("\nCategory " + index + "");
                            //
                            CmdRecord cmd = new CmdRecord(attb.GlobalName,
                                                          attb.Tag,
                                                          attb.Description,
                                                          attb.Author,
                                                          attb.Email,
                                                          attb.WebLink,
                                                          category
                                                          );
                            // Check if Database contains this cmd
                            if (!this.CmdTableRecord.Contains(attb.GlobalName))
                            {
                                this.CmdTableRecord.Add(attb.GlobalName,
                                                        attb.Tag,
                                                        !String.IsNullOrEmpty(attb.Tag) ? "[" + attb.Tag + "] " + GetCommandDescription(attb.Description) : GetCommandDescription(attb.Description),
                                                        attb.Author,
                                                        attb.Email,
                                                        attb.WebLink,
                                                        category
                                                        );
                                //if (!String.IsNullOrEmpty(cat.Category))
                                //{
                                //    GLOBAL.WriteMessage("Category: " + cat.Category);
                                //}
                            }
                        }
                    }
                }
            }
            //
        }
Example #10
0
        public dynamic FabDumpItem(ResultBuffer args)
        {
            Autodesk.AutoCAD.EditorInput.Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            List <string> res = new List <string>();
            ObjectId      ent;
            string        path       = "";
            int           OutputType = 3;
            dynamic       itm        = null;

            if (args != null)
            {
                TypedValue[] argarray = args.AsArray();
                if (argarray.Length >= 1 && argarray[0].TypeCode == (int)LispDataType.ObjectId)
                {
                    ent = (ObjectId)argarray[0].Value;
                    try { itm = Autodesk.Fabrication.Job.GetFabricationItemFromACADHandle(ent.Handle.ToString()); }
                    catch (System.Exception) { }
                }
                else if (argarray.Length >= 1 && argarray[0].TypeCode == (int)LispDataType.Text)
                {
                    itm = (string)argarray[0].Value;
                    if (itm.StartsWith("$") == true && VarCache.ContainsKey(hand.VariableName(itm)) == true)
                    {
                        itm = VarCache[hand.VariableName(itm)];
                    }
                }
                if (argarray.Length >= 2 && argarray[1].TypeCode == (int)LispDataType.Text)
                {
                    path = (string)argarray[1].Value;
                }
                if (argarray.Length >= 3 && argarray[2].TypeCode == (int)LispDataType.Int16)
                {
                    OutputType = Convert.ToInt32(argarray[2].Value);
                }

                if (itm != null && path.Length > 1)
                {
                    res = Sequencing.GetReflectedTypesList(itm, new List <string>(path.Split('.')));
                    if (res.Count >= 1)
                    {
                        ed.WriteMessage("\n\n");
                        foreach (string s in res)
                        {
                            if (s.StartsWith("Property:") == true)
                            {
                                if (OutputType == 1 || OutputType == 3)
                                {
                                    ed.WriteMessage(s + "\n");
                                }
                            }
                            else if (s.StartsWith("Method:") == true)
                            {
                                if (OutputType == 2 || OutputType == 3)
                                {
                                    ed.WriteMessage(s + "\n");
                                }
                            }
                        }
                    }
                }
            }
            ResultBuffer rb = new ResultBuffer();

            rb.Add(new TypedValue((int)LispDataType.ListBegin));
            foreach (string s in res)
            {
                rb.Add(new TypedValue((int)LispDataType.Text, s));
            }
            rb.Add(new TypedValue((int)LispDataType.ListEnd));
            if (OutputType >= 1 && OutputType <= 3)
            {
                return(null);
            }
            else
            {
                return(rb);
            }
        }