public static bool SetPlotSettings(_AcDb.ResultBuffer rb)
        {
            try
            {
                var arr = rb.AsArray();

                string loName, device, pageSize, styleSheet;
                double?scaleNumerator, scaleDenominator;
                short? rotation;

                TolerantGet(arr, out loName, 1);
                TolerantGet(arr, out device, 2);
                TolerantGet(arr, out pageSize, 3);
                TolerantGet(arr, out styleSheet, 4);
                TolerantGet(arr, out scaleNumerator, 5);
                TolerantGet(arr, out scaleDenominator, 6);
                TolerantGet(arr, out rotation, 7);

                return(SetPlotSettings(loName, device, pageSize, styleSheet, scaleNumerator, scaleDenominator, rotation));
            }
            catch (Exception ex)
            {
                log.Error(ex.Message, ex);
                return(false);
            }
        }
示例#2
0
        public static void TextToClipBoard(_AcDb.ResultBuffer rb)
        {
            try
            {
                if (rb == null)
                {
                    return;
                }
                _AcDb.TypedValue[] values = rb.AsArray();
                if (values == null || values.Length < 1)
                {
                    return;
                }
                if (values[0].Value == null)
                {
                    return;
                }

                string clipBoardText = values[0].Value.ToString();
                if (string.IsNullOrEmpty(clipBoardText))
                {
                    return;
                }

                System.Windows.Clipboard.SetText(clipBoardText);
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(string.Format(CultureInfo.CurrentCulture, "Fehler in TextToClipBoard: {0}", ex.Message), "TextToClipBoard");
            }
        }
示例#3
0
        public bool Plan2ExcelToBlock(_AcDb.ResultBuffer rb)
        {
            _AcEd.Editor ed = _AcAp.Application.DocumentManager.MdiActiveDocument.Editor;
            try
            {
                if (rb == null)
                {
                    ShowCallInfoImport(ed);
                    return(false);
                }
                _AcDb.TypedValue[] values = rb.AsArray();
                if (values == null || values.Length < 2)
                {
                    ShowCallInfoImport(ed);
                    return(false);
                }
                // Get ExcelFileName from Args
                if (values[0].Value == null)
                {
                    ShowCallInfoImport(ed);
                    return(false);
                }
                string excelFileName = values[0].Value.ToString();
                if (string.IsNullOrEmpty(excelFileName))
                {
                    ShowCallInfoImport(ed);
                    return(false);
                }

                bool createChangeLines = true;
                switch (values[1].TypeCode)
                {
                case 5019:
                    createChangeLines = false;
                    break;

                case 5021:
                    createChangeLines = true;
                    break;

                default:
                    ShowCallInfoImport(ed);
                    return(false);
                }

                // Start Import
                StartImport(excelFileName, createChangeLines);

                return(true);
            }
            catch (System.Exception ex)
            {
                log.Error(ex.Message);
                string msg = string.Format(CultureInfo.CurrentCulture, "Fehler in (Plan2ExcelToBlock): {0}", ex.Message);
                ed.WriteMessage("\n" + msg);
                System.Windows.Forms.MessageBox.Show(ex.Message, "Plan2ExcelToBlock");
                return(false);
            }
        }
示例#4
0
        public bool Plan2BlockToExcel(_AcDb.ResultBuffer rb)
        {
            _AcEd.Editor ed = _AcAp.Application.DocumentManager.MdiActiveDocument.Editor;
            try
            {
                if (rb == null)
                {
                    ShowCallInfo(ed);
                    return(false);
                }
                _AcDb.TypedValue[] values = rb.AsArray();
                if (values == null || values.Length < 2)
                {
                    ShowCallInfo(ed);
                    return(false);
                }
                // Get Blockname from Args
                if (values[0].Value == null)
                {
                    ShowCallInfo(ed);
                    return(false);
                }
                string blockName = values[0].Value.ToString();
                if (string.IsNullOrEmpty(blockName))
                {
                    ShowCallInfo(ed);
                    return(false);
                }

                // Get ExcelFileName from Args
                if (values[1].Value == null)
                {
                    ShowCallInfo(ed);
                    return(false);
                }
                string excelFileName = values[1].Value.ToString();
                if (string.IsNullOrEmpty(excelFileName))
                {
                    ShowCallInfo(ed);
                    return(false);
                }

                // Start Export
                StartExport(blockName, excelFileName);

                return(true);
            }
            catch (System.Exception ex)
            {
                log.Error(ex.Message);
                string msg = string.Format(CultureInfo.CurrentCulture, "Fehler in (Plan2BlockToExcel): {0}", ex.Message);
                ed.WriteMessage("\n" + msg);
                System.Windows.Forms.MessageBox.Show(ex.Message, "Plan2BlockToExcel");
                return(false);
            }
        }
示例#5
0
        public static void SetXData(AcDb.ObjectId objectId, AcDb.ResultBuffer valueXData)
        {
            AcAp.Document doc = AcApp.DocumentManager.MdiActiveDocument;

            using (AcDb.Transaction tr = doc.TransactionManager.StartTransaction())
            {
                AcDb.DBObject obj = tr.GetObject(objectId, AcDb.OpenMode.ForWrite);
                AddRegAppTableRecord((string)valueXData.AsArray()[0].Value);
                obj.XData = valueXData;
                valueXData.Dispose();
                tr.Commit();
            }
        }
示例#6
0
        public static bool Plan2RemoveHyperLinks(_AcDb.ResultBuffer rb)
        {
            var doc = _AcAp.Application.DocumentManager.MdiActiveDocument;

            _AcDb.Database           db      = _AcAp.Application.DocumentManager.MdiActiveDocument.Database;
            _AcDb.TransactionManager dbTrans = db.TransactionManager;
            _AcEd.Editor             ed      = doc.Editor;

            try
            {
                if (rb == null)
                {
                    ed.WriteMessage("Aufruf: (Plan2RemoveHyperLinks el)");
                    return(false);
                }

                var typedValues = rb.AsArray();
                if (typedValues == null || typedValues.Length != 1)
                {
                    ed.WriteMessage("Aufruf: (Plan2RemoveHyperLinks el)");
                    return(false);
                }

                if (typedValues[0].TypeCode != (short)_AcBrx.LispDataType.ObjectId)
                {
                    ed.WriteMessage("Aufruf: (Plan2RemoveHyperLinks el)");
                    return(false);
                }

                using (_AcDb.Transaction trans = dbTrans.StartTransaction())
                {
                    _AcDb.Entity ent = trans.GetObject((_AcDb.ObjectId)typedValues[0].Value, _AcDb.OpenMode.ForWrite) as _AcDb.Entity;
                    if (ent != null)
                    {
                        //ent.Hyperlinks.Clear(); // -> crashes
                        while (ent.Hyperlinks.Count > 0)
                        {
                            ent.Hyperlinks.RemoveAt(0);
                        }
                    }
                    trans.Commit();
                }
                return(true);
            }
            catch (Exception ex)
            {
                ed.WriteMessage("Aufruf: (Plan2RemoveHyperLinks el)");
            }
            return(false);
        }
        internal List <ZuweisungsInfo> GetAssignmentsDictOld()
        {
            List <ZuweisungsInfo> zwInfos = new List <ZuweisungsInfo>();

            try
            {
                //using (var rb = new ResultBuffer(new TypedValue((int)Autodesk.AutoCAD.Runtime.LispDataType.Text, "c:Plan2AutoIdVergabeSetAssignments")))
                using (var rb = new _AcDb.ResultBuffer(new _AcDb.TypedValue((int)_AcBrx.LispDataType.Text, "c:GetPlan2AutoIdVergabeAssignmentsDict")))
                {
                    int stat = 0;
                    _AcDb.ResultBuffer res = CADDZone.AutoCAD.Samples.AcedInvokeSample.InvokeLisp(rb, ref stat);
                    if (stat == RTNORM && res != null)
                    {
                        var arr = res.AsArray();
                        if (arr != null && arr.Length > 1)
                        {
                            int pos = 0;

                            while (pos < arr.Length)
                            {
                                // list begin
                                var rbFrom = arr[pos + 1];
                                var rbTo   = arr[pos + 2];
                                // dotted pair

                                zwInfos.Add(new ZuweisungsInfo()
                                {
                                    FromAtt = rbFrom.Value.ToString(), ToAtt = rbTo.Value.ToString()
                                });

                                pos += 4;
                            }
                        }
                        res.Dispose();
                    }
                }
            }
            catch (Exception)
            {
                // todo: log error
            }



            return(zwInfos);
        }
示例#8
0
 private static void GetConfiguration()
 {
     _CurrentConfig = string.Empty;
     using (var rb = new _AcDb.ResultBuffer(new _AcDb.TypedValue((int)_AcBrx.LispDataType.Text, "c:Plan2CurrentConfig")))
     {
         int stat = 0;
         _AcDb.ResultBuffer res = CADDZone.AutoCAD.Samples.AcedInvokeSample.InvokeLisp(rb, ref stat);
         if (stat == RTNORM && res != null)
         {
             _CurrentConfig = res.AsArray()[0].Value.ToString();
             res.Dispose();
         }
         else
         {
             throw new InvalidOperationException("Konnte Konfigurationsdateiname nicht ermitteln!");
         }
     }
 }
        private static bool GetArgsFromRb(_AcDb.ResultBuffer args, out string FileName, out string Ext, out string Title, out bool Multiple)
        {
            FileName = ""; Ext = ""; Title = ""; Multiple = false;
            _AcDb.TypedValue[] array = args.AsArray();
            if (array.Length < 3)
            {
                return(false);
            }
            if (array[0].TypeCode != (int)_AcBrx.LispDataType.Text)
            {
                return(false);
            }
            Title = array[0].Value.ToString();
            if (array[1].TypeCode != (int)_AcBrx.LispDataType.Text)
            {
                return(false);
            }
            FileName = array[1].Value.ToString();
            if (array[2].TypeCode != (int)_AcBrx.LispDataType.Text)
            {
                return(false);
            }
            Ext = array[2].Value.ToString();
            if (array.Length > 3)
            {
                if (array[3].TypeCode == (int)_AcBrx.LispDataType.T_atom)
                {
                    if (array[3].Value == null)
                    {
                        Multiple = false;
                    }
                    else
                    {
                        Multiple = (bool)array[3].Value;
                    }
                }
            }

            return(true);
        }
示例#10
0
        public _AcDb.ResultBuffer Plan2GetExcelToBlockDwgs(_AcDb.ResultBuffer rb)
        {
            _AcEd.Editor ed = _AcAp.Application.DocumentManager.MdiActiveDocument.Editor;
            try
            {
                if (rb == null)
                {
                    ShowCallInfoDwgs(ed);
                    return(null);
                }
                _AcDb.TypedValue[] values = rb.AsArray();
                if (values == null || values.Length < 1)
                {
                    ShowCallInfoDwgs(ed);
                    return(null);
                }
                // Get ExcelFileName from Args
                if (values[0].Value == null)
                {
                    ShowCallInfoDwgs(ed);
                    return(null);
                }
                string excelFileName = values[0].Value.ToString();
                if (string.IsNullOrEmpty(excelFileName))
                {
                    ShowCallInfoDwgs(ed);
                    return(null);
                }

                return(GetDwgNames(excelFileName));
            }
            catch (System.Exception ex)
            {
                log.Error(ex.Message);
                string msg = string.Format(CultureInfo.CurrentCulture, "Fehler in (Plan2GetExcelToBlockDwgs): {0}", ex.Message);
                ed.WriteMessage("\n" + msg);
                System.Windows.Forms.MessageBox.Show(ex.Message, "Plan2GetExcelToBlockDwgs");
                return(null);
            }
        }
示例#11
0
        public static void Plan2InsertFehlerLines(_AcDb.ResultBuffer rb)
        {
            var arr = rb.AsArray();

            if (arr.Length < 6)
            {
                return;
            }
            string layer = arr[0].Value.ToString();
            // length 1
            // angle 2
            // colorindex 3
            // LB 4

            List <_AcGe.Point3d> pts = new List <_AcGe.Point3d>();

            for (int i = 5; i < arr.Length - 1; i++)
            {
                pts.Add((_AcGe.Point3d)arr[i].Value);
            }
            Globs.InsertFehlerLines(pts, layer);
        }
示例#12
0
        private static bool GetArgs2(_AcDb.ResultBuffer rb, ref string current, List <string> configs)
        {
            if (rb == null)
            {
                return(false);
            }
            _AcDb.TypedValue[] values = rb.AsArray();
            if (values.Length <= 2)
            {
                return(false);
            }

            current = values[1].Value.ToString();

            for (int i = 2; i < (values.Length - 1); i++)
            {
                var v = values[i];
                configs.Add(v.Value.ToString());
            }

            return(true);
        }
示例#13
0
        public static bool Plan2FinishPlot(_AcDb.ResultBuffer rb)
        {
            _AcEd.Editor ed = _AcAp.Application.DocumentManager.MdiActiveDocument.Editor;
            try
            {
                if (rb == null)
                {
                    return(false);
                }
                _AcDb.TypedValue[] values = rb.AsArray();
                if (values == null || values.Length < 1)
                {
                    return(false);
                }
                if (values[0].Value == null)
                {
                    return(false);
                }
                string dirName = values[0].Value.ToString();
                if (string.IsNullOrEmpty(dirName))
                {
                    return(false);
                }
                if (!System.IO.Directory.Exists(dirName))
                {
                    return(false);
                }

                return(Plan2FinishPlot(dirName));
            }
            catch (System.Exception ex)
            {
                string msg = string.Format(CultureInfo.CurrentCulture, "Fehler in (Plan2FinishPlot): {0}", ex.Message);
                ed.WriteMessage("\n" + msg);
                System.Windows.Forms.MessageBox.Show(ex.Message, "Plan2FinishPlot");
                return(false);
            }
        }
示例#14
0
        public static bool Plan2AddHyperLink(_AcDb.ResultBuffer rb)
        {
            var doc = _AcAp.Application.DocumentManager.MdiActiveDocument;

            _AcDb.Database           db      = _AcAp.Application.DocumentManager.MdiActiveDocument.Database;
            _AcDb.TransactionManager dbTrans = db.TransactionManager;
            _AcEd.Editor             ed      = doc.Editor;

            try
            {
                _AcDb.ObjectId oid;
                string         description, name, sublocation;
                if (rb == null)
                {
                    ed.WriteMessage("Aufruf: (Plan2AddHyperLink el description name sublocation)");
                    return(false);
                }

                var typedValues = rb.AsArray();
                if (typedValues == null || typedValues.Length != 4)
                {
                    ed.WriteMessage("Aufruf: (Plan2AddHyperLink el description name sublocation)");
                    return(false);
                }

                if (typedValues[0].TypeCode != (short)_AcBrx.LispDataType.ObjectId)
                {
                    ed.WriteMessage("Aufruf: (Plan2AddHyperLink el description name sublocation)");
                    return(false);
                }

                oid = (_AcDb.ObjectId)typedValues[0].Value;

                if (typedValues[1].TypeCode != (short)_AcBrx.LispDataType.Text)
                {
                    ed.WriteMessage("Aufruf: (Plan2AddHyperLink el description name sublocation)");
                    return(false);
                }
                description = typedValues[1].Value.ToString();

                if (typedValues[2].TypeCode != (short)_AcBrx.LispDataType.Text)
                {
                    ed.WriteMessage("Aufruf: (Plan2AddHyperLink el description name sublocation)");
                    return(false);
                }
                name = typedValues[2].Value.ToString();

                if (typedValues[3].TypeCode != (short)_AcBrx.LispDataType.Text)
                {
                    ed.WriteMessage("Aufruf: (Plan2AddHyperLink el description name sublocation)");
                    return(false);
                }
                sublocation = typedValues[3].Value.ToString();


                using (_AcDb.Transaction trans = dbTrans.StartTransaction())
                {
                    _AcDb.Entity ent = trans.GetObject((_AcDb.ObjectId)typedValues[0].Value, _AcDb.OpenMode.ForWrite) as _AcDb.Entity;
                    if (ent != null)
                    {
                        _AcDb.HyperLink hyperLink = new _AcDb.HyperLink();
                        hyperLink.Description = description;
                        hyperLink.Name        = name;
                        hyperLink.SubLocation = sublocation;

                        ent.Hyperlinks.Add(hyperLink);
                    }
                    trans.Commit();
                }
                return(true);
            }
            catch (Exception ex)
            {
                ed.WriteMessage("Aufruf: (Plan2RemoveHyperLinks el)");
            }
            return(false);
        }
示例#15
0
        public static void InoCallProcess(_AcDb.ResultBuffer rb)
        {
            try
            {
                if (rb == null)
                {
                    return;
                }
                _AcDb.TypedValue[] values = rb.AsArray();
                if (values == null || values.Length < 1)
                {
                    return;
                }
                if (values[0].Value == null)
                {
                    return;
                }
                string fileName = values[0].Value.ToString();
                if (string.IsNullOrEmpty(fileName))
                {
                    return;
                }

                string args = string.Empty;
                if (values.Length > 1)
                {
                    args = values[1].Value.ToString();
                }

                // Simple variante
                //if (string.IsNullOrEmpty(args))
                //{
                //    System.Diagnostics.Process.Start(fileName);
                //}
                //else
                //{
                //    System.Diagnostics.Process.Start(fileName, args);
                //}

                _AcEd.Editor ed = _AcAp.Application.DocumentManager.MdiActiveDocument.Editor;

                // Variante with output
                int exitCode = -1;
                // -> async writings to editor are ignored
                //ExecuteCommandAsyncOut(fileName, args, ref exitCode, ed);
                string error  = string.Empty;
                string output = string.Empty;

                log.InfoFormat(CultureInfo.InvariantCulture, "InoCallProcess: args='{0}', filename='{1}'.", args, fileName);

                ExecuteCommandSyncOut(fileName, args, ref error, ref output, ref exitCode);
                if (!string.IsNullOrEmpty(output))
                {
                    ed.WriteMessage("\n" + output);
                    log.Info(output);
                }
                if (!string.IsNullOrEmpty(error))
                {
                    ed.WriteMessage("\nError>>" + error);
                    log.Warn("\nError>>" + error);
                }
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(string.Format(CultureInfo.CurrentCulture, "Fehler in CallProcess: {0}", ex.Message), "CallProcess");
            }
        }
示例#16
0
 private static void GetArgs(_AcDb.ResultBuffer rb)
 {
     _AcDb.TypedValue[] values = rb.AsArray();
     _FileName = values[0].Value.ToString();
 }
示例#17
0
        public static bool CreateCallRotateBat(_AcDb.ResultBuffer rb)
        {
            const string cropBatName = "CallCrop.BAT";

            _AcEd.Editor ed = _AcAp.Application.DocumentManager.MdiActiveDocument.Editor;


            try
            {
                if (rb == null)
                {
                    ed.WriteMessage("\nAufruf: (CreateCallRotateBat CropBatDir PdfDir)");
                    return(false);
                }
                _AcDb.TypedValue[] values = rb.AsArray();
                if (values == null || values.Length < 2 || values[0].Value == null || values[1] == null)
                {
                    ed.WriteMessage("\nAufruf: (CreateCallRotateBat CropBatDir PdfDir)");
                    return(false);
                }

                string cropBatDir = values[0].Value.ToString();
                string pdfDir     = values[1].Value.ToString();
                if (string.IsNullOrEmpty(cropBatDir) || !System.IO.Directory.Exists(cropBatDir))
                {
                    ed.WriteMessage(string.Format(CultureInfo.CurrentCulture, "\n(CreateCallRotateBat '{0}' '{1}'): Verzeichnis '{0}' existiert nicht!", cropBatDir, pdfDir));
                    return(false);
                }
                if (string.IsNullOrEmpty(pdfDir) || !System.IO.Directory.Exists(pdfDir))
                {
                    ed.WriteMessage(string.Format(CultureInfo.CurrentCulture, "\n(CreateCallRotateBat '{0}' '{1}'): Verzeichnis '{1}' existiert nicht!", cropBatDir, pdfDir));
                    return(false);
                }

                string cropBatFileName = System.IO.Path.Combine(cropBatDir, cropBatName);
                try
                {
                    if (System.IO.File.Exists(cropBatFileName))
                    {
                        System.IO.File.Delete(cropBatFileName);
                    }
                }
                catch (System.Exception)
                {
                }
                if (System.IO.File.Exists(cropBatFileName))
                {
                    ed.WriteMessage(string.Format(CultureInfo.CurrentCulture, "\nFehler in CreateCallRotateBat: Konnte Datei '{0}' nicht löschen!", cropBatFileName));
                    return(false);
                }
                if (!pdfDir.ToUpperInvariant().Contains("T:"))
                {
                    ed.WriteMessage(string.Format(CultureInfo.CurrentCulture, "\nFehler in CreateCallRotateBat: PdfDir '{0}' muss auf T: liegen!", pdfDir));
                    return(false);
                }

                //pdfDir = pdfDir.ToUpperInvariant().Replace("T:", "E:");

                string txt = string.Format(CultureInfo.InvariantCulture, "call c:\\pdftemp\\Rotate.bat \"{0}\" \"{0}\"\n", pdfDir);
                System.IO.File.WriteAllText(cropBatFileName, txt);

                return(true);
            }
            catch (System.Exception ex)
            {
                ed.WriteMessage(string.Format(CultureInfo.CurrentCulture, "\nFehler in CreateCallRotateBat! {0}'", ex.Message));
            }
            return(false);
        }