Beispiel #1
0
        public static _AcDb.ResultBuffer NetSetPlan2Config(_AcDb.ResultBuffer rb)
        {
            try
            {
                TheConfiguration.Loaded = false;

                List <string> existingConfigs = new List <string>();
                string        current         = "";
                if (!GetArgs2(rb, ref current, existingConfigs))
                {
                    log.Error("No valid configlist!");
                }

                using (SetConfigForm frm = new SetConfigForm(current, existingConfigs))
                {
                    System.Windows.Forms.DialogResult res = _AcAp.Application.ShowModalDialog(frm);
                    if (res == System.Windows.Forms.DialogResult.Cancel)
                    {
                        return(null);
                    }
                    else
                    {
                        return(new _AcDb.ResultBuffer(new _AcDb.TypedValue((int)_AcBrx.LispDataType.Text, frm.Configuration)));
                    }
                }
            }
            catch (System.Exception ex)
            {
                _AcAp.Application.ShowAlertDialog(string.Format(CultureInfo.CurrentCulture, "Fehler in NetSetPlan2Config aufgetreten!\n{0}", ex.Message));
            }
            return(null);
        }
        public static _AcDb.TypedValue LispSaveFileDialog(_AcDb.ResultBuffer args)
        {
            if (args == null)
            {
                return(new _AcDb.TypedValue((int)_AcBrx.LispDataType.Nil));
            }
            string FileName, Ext, Title;
            bool   Multiple;

            if (!GetArgsFromRb(args, out FileName, out Ext, out Title, out Multiple))
            {
                return(new _AcDb.TypedValue((int)_AcBrx.LispDataType.Nil));
            }
            else
            {
                _AcWnd.SaveFileDialog             sfd = new _AcWnd.SaveFileDialog(Title, FileName, Ext, "LispSFD", _AcWnd.SaveFileDialog.SaveFileDialogFlags.AllowAnyExtension);
                System.Windows.Forms.DialogResult dr  = sfd.ShowDialog();
                if (dr == System.Windows.Forms.DialogResult.OK)
                {
                    return(new _AcDb.TypedValue((int)_AcBrx.LispDataType.Text, sfd.Filename));
                }
                else
                {
                    return(new _AcDb.TypedValue((int)_AcBrx.LispDataType.Nil));
                }
            }
        }
Beispiel #3
0
        private AcDb.ObjectId AddBorders()
        {
            AcDb.Polyline2d borderParcel = ServiceSimpleElements.CreatePolyline2d(this.Parcel.Points, true);
            borderParcel.LayerId = ServiceCAD.CreateLayer(settingsDrawing.Plan.FillParcel.Layer);
            AcDb.ObjectId idBorderParcel = ServiceCAD.InsertObject(borderParcel);

            AcDb.ResultBuffer xData = new AcDb.ResultBuffer();
            int dxfCode;

            AcDb.TypedValue typedValue;

            dxfCode    = (int)AcDb.DxfCode.ExtendedDataRegAppName;
            typedValue = new AcDb.TypedValue(dxfCode, "Земельна ділянка");
            xData.Add(typedValue);

            foreach (LandInfo infoValue in this.Parcel.Info)
            {
                dxfCode    = (int)AcDb.DxfCode.ExtendedDataAsciiString;
                typedValue = new AcDb.TypedValue(dxfCode, "<" + infoValue.Key + "> " + infoValue.Value);
                xData.Add(typedValue);
            }

            ServiceCAD.SetXData(idBorderParcel, xData);

            return(idBorderParcel);
        }
Beispiel #4
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");
            }
        }
Beispiel #5
0
        static public void GetXData()
        {
            AcAp.Document doc = AcApp.DocumentManager.MdiActiveDocument;
            AcEd.Editor   ed  = doc.Editor;

            AcEd.PromptEntityOptions opt = new AcEd.PromptEntityOptions("\nSelect entity: ");
            AcEd.PromptEntityResult  res = ed.GetEntity(opt);

            if (res.Status == AcEd.PromptStatus.OK)
            {
                using (AcDb.Transaction tr = doc.TransactionManager.StartTransaction())
                {
                    AcDb.DBObject     obj = tr.GetObject(res.ObjectId, AcDb.OpenMode.ForRead);
                    AcDb.ResultBuffer rb  = obj.XData;
                    if (rb == null)
                    {
                        ed.WriteMessage("\nEntity does not have XData attached.");
                    }
                    else
                    {
                        int n = 0;
                        foreach (AcDb.TypedValue tv in rb)
                        {
                            ed.WriteMessage("\nTypedValue {0} - type: {1}, value: {2}", n++, tv.TypeCode, tv.Value);
                        }
                        rb.Dispose();
                    }
                }
            }
        }
        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);
            }
        }
Beispiel #7
0
        public static bool CallCropBat(_AcDb.ResultBuffer rb)
        {
            _AcEd.Editor ed       = _AcAp.Application.DocumentManager.MdiActiveDocument.Editor;
            string       taskName = "CallCropBat";

            try
            {
                using (TaskService tasksrvc = new TaskService("server", "pdfcrop", "workgroup", "pdf"))
                {
                    Task task = tasksrvc.FindTask(taskName);
                    if (task != null)
                    {
                        var t1 = task.Run();
                        ed.WriteMessage(string.Format("\nTask '{0}' ausgeführt.", taskName));
                        return(true);
                    }
                    else
                    {
                        ed.WriteMessage(string.Format("\nTask '{0}' nicht gefunden!", taskName));
                    }
                }
            }
            catch (System.Exception ex)
            {
                ed.WriteMessage(string.Format(CultureInfo.CurrentCulture, "\nFehler in CallCropBat! {0}'", ex.Message));
            }
            return(false);
        }
Beispiel #8
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);
            }
        }
Beispiel #9
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);
            }
        }
Beispiel #10
0
        public _AcDb.ResultBuffer LayoutListSelected(_AcDb.ResultBuffer args)
        {
            if (args != null)
            {
                throw new TooFewArgsException();
            }

            _AcAp.Document doc = _AcAp.Application.DocumentManager.MdiActiveDocument;
            _AcDb.Database db  = doc.Database;
            //Editor ed = doc.Editor;
            //LayoutManager layoutMgr = LayoutManager.Current;
            List <string> layouts = new List <string>();

            _AcDb.ResultBuffer res = new _AcDb.ResultBuffer();

            using (_AcDb.Transaction tr = db.TransactionManager.StartTransaction())
            {
                _AcDb.DBDictionary layoutDic =
                    (_AcDb.DBDictionary)tr.GetObject(db.LayoutDictionaryId, _AcDb.OpenMode.ForRead, openErased: false);

                foreach (_AcDb.DBDictionaryEntry entry in layoutDic)
                {
                    _AcDb.Layout layout =
                        (_AcDb.Layout)tr.GetObject(entry.Value, _AcDb.OpenMode.ForRead);

                    string layoutName = layout.LayoutName;

                    if (layout.TabSelected)
                    {
                        layouts.Add(layoutName);
                    }
                }

                tr.Commit();
            }

            layouts.Remove("Model");

            if (0 < layouts.Count)
            {
                layouts.Sort();

                foreach (string layoutName in layouts)
                {
                    res.Add(new _AcDb.TypedValue((int)(_AcBrx.LispDataType.Text), layoutName));
                }

                return(res);
            }

            else
            {
                return(null);
            }
        }
 public static void OpenPlotSettings(_AcDb.ResultBuffer rb)
 {
     try
     {
         _AcAp.Application.DocumentManager.MdiActiveDocument.SendStringToExecute("Plot ", true, false, false);
     }
     catch (Exception ex)
     {
         log.Error(ex.Message, ex);
     }
 }
Beispiel #12
0
 private static void SetAssignmentsDict()
 {
     using (var rb = new _AcDb.ResultBuffer(new _AcDb.TypedValue((int)_AcBrx.LispDataType.Text, "c:Plan2AutoIdVergabeSetAssignments")))
     {
         int stat = 0;
         _AcDb.ResultBuffer res = CADDZone.AutoCAD.Samples.AcedInvokeSample.InvokeLisp(rb, ref stat);
         if (stat == RTNORM && res != null)
         {
             res.Dispose();
         }
     }
 }
Beispiel #13
0
        // Helper for acedInvoke()

        public static _AcDb.ResultBuffer InvokeLisp(_AcDb.ResultBuffer args, ref int stat)
        {
            IntPtr rb = IntPtr.Zero;

            stat = acedInvoke(args.UnmanagedObject, out rb);
            if (stat == (int)_AcEd.PromptStatus.OK && rb != IntPtr.Zero)
            {
                return((_AcDb.ResultBuffer)
                       _AcTrx.DisposableWrapper.Create(typeof(_AcDb.ResultBuffer), rb, true));
            }
            return(null);
        }
Beispiel #14
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();
            }
        }
Beispiel #15
0
        static void PrintResbuf(_AcDb.ResultBuffer rb)
        {
            string s = "\n-----------------------------";

            foreach (_AcDb.TypedValue val in rb)
            {
                s += string.Format("\n{0} -> {1}", val.TypeCode,
                                   val.Value.ToString());
            }
            s += "\n-----------------------------";
            _AcAp.Application.DocumentManager.MdiActiveDocument.
            Editor.WriteMessage(s);
        }
Beispiel #16
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);
        }
Beispiel #17
0
        public static void InvokeCLisp(string funcNameWithoutC)
        {
            _AcDb.ResultBuffer args = new _AcDb.ResultBuffer();
            int stat = 0;

            args.Add(new _AcDb.TypedValue(RTSTR, "c:" + funcNameWithoutC));

            _AcDb.ResultBuffer res = InvokeLisp(args, ref stat);
            if (stat == RTNORM && res != null)
            {
                PrintResbuf(res);
                res.Dispose();
            }
        }
Beispiel #18
0
        public static void InvokeCGeoin()
        {
            _AcDb.ResultBuffer args = new _AcDb.ResultBuffer();
            int stat = 0;

            args.Add(new _AcDb.TypedValue(RTSTR, "c:geoin"));

            _AcDb.ResultBuffer res = InvokeLisp(args, ref stat);
            if (stat == RTNORM && res != null)
            {
                PrintResbuf(res);
                res.Dispose();
            }
        }
        public static _AcDb.ResultBuffer LispOpenFileDialog2(_AcDb.ResultBuffer args)
        {
            if (args == null)
            {
                return(new _AcDb.ResultBuffer(new _AcDb.TypedValue((int)_AcBrx.LispDataType.Nil)));
            }
            string FileName, Ext, Title;
            bool   Multiple;

            if (!GetArgsFromRb(args, out FileName, out Ext, out Title, out Multiple))
            {
                return(new _AcDb.ResultBuffer(new _AcDb.TypedValue((int)_AcBrx.LispDataType.Nil)));
            }
            else
            {
                System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
                ofd.CheckFileExists = true;
                ofd.Filter          = Ext + "|*." + Ext;
                ofd.Multiselect     = Multiple;
                ofd.Title           = Title;
                if (!string.IsNullOrEmpty(FileName))
                {
                    ofd.InitialDirectory = System.IO.Path.GetDirectoryName(FileName);
                }

                System.Windows.Forms.DialogResult res = ofd.ShowDialog();
                if (res == System.Windows.Forms.DialogResult.OK)
                {
                    if (Multiple)
                    {
                        _AcDb.ResultBuffer rb = new _AcDb.ResultBuffer();
                        foreach (string fname in ofd.FileNames)
                        {
                            rb.Add(new _AcDb.TypedValue((int)_AcBrx.LispDataType.Text, fname));
                        }
                        return(rb);
                    }
                    else
                    {
                        return(new _AcDb.ResultBuffer(new _AcDb.TypedValue((int)_AcBrx.LispDataType.Text, ofd.FileName)));
                    }
                }
                else
                {
                    return(new _AcDb.ResultBuffer(new _AcDb.TypedValue((int)_AcBrx.LispDataType.Nil)));
                }
            }
        }
        public static _AcDb.ResultBuffer LispOpenFileDialog(_AcDb.ResultBuffer args)
        {
            if (args == null)
            {
                return(new _AcDb.ResultBuffer(new _AcDb.TypedValue((int)_AcBrx.LispDataType.Nil)));
            }
            string FileName, Ext, Title;
            bool   Multiple;

            if (!GetArgsFromRb(args, out FileName, out Ext, out Title, out Multiple))
            {
                return(new _AcDb.ResultBuffer(new _AcDb.TypedValue((int)_AcBrx.LispDataType.Nil)));
            }
            else
            {
                _AcWnd.OpenFileDialog ofd;
                if (Multiple)
                {
                    ofd = new _AcWnd.OpenFileDialog(Title, FileName, Ext, "LispOFD", _AcWnd.OpenFileDialog.OpenFileDialogFlags.AllowAnyExtension | _AcWnd.OpenFileDialog.OpenFileDialogFlags.AllowMultiple);
                }
                else
                {
                    ofd = new _AcWnd.OpenFileDialog(Title, FileName, Ext, "LispOFD", _AcWnd.OpenFileDialog.OpenFileDialogFlags.AllowAnyExtension);
                }
                System.Windows.Forms.DialogResult dr = ofd.ShowDialog();
                if (dr == System.Windows.Forms.DialogResult.OK)
                {
                    if (Multiple)
                    {
                        _AcDb.ResultBuffer rb = new _AcDb.ResultBuffer();
                        foreach (string fname in ofd.GetFilenames())
                        {
                            rb.Add(new _AcDb.TypedValue((int)_AcBrx.LispDataType.Text, fname));
                        }
                        return(rb);
                    }
                    else
                    {
                        return(new _AcDb.ResultBuffer(new _AcDb.TypedValue((int)_AcBrx.LispDataType.Text, ofd.Filename)));
                    }
                }
                else
                {
                    return(new _AcDb.ResultBuffer(new _AcDb.TypedValue((int)_AcBrx.LispDataType.Nil)));
                }
            }
        }
        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);
        }
 static public void test()
 {
     _AcEd.PromptResult rs =
         _AcAp.Application.DocumentManager.MdiActiveDocument.Editor.GetString("\nEnter lisp expression: ");
     if (rs.Status == _AcEd.PromptStatus.OK && rs.StringResult != "")
     {
         _AcDb.ResultBuffer rb = AcadEvalLisp(rs.StringResult);
         if (rb != null)
         {
             PrintResbuf(rb);
         }
         else
         {
             _AcAp.Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("\nError in evaluation");
         }
     }
 }
Beispiel #23
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!");
         }
     }
 }
Beispiel #24
0
        public static AcDb.ResultBuffer GetXData(AcDb.ObjectId objectId)
        {
            AcAp.Document doc = AcApp.DocumentManager.MdiActiveDocument;

            using (AcDb.Transaction tr = doc.TransactionManager.StartTransaction())
            {
                AcDb.DBObject     obj          = tr.GetObject(objectId, AcDb.OpenMode.ForRead);
                AcDb.ResultBuffer resultBuffer = obj.XData;
                if (resultBuffer == null)
                {
                    return(null);
                }
                else
                {
                    return(resultBuffer);
                }
            }
        }
Beispiel #25
0
        public static _AcDb.ResultBuffer ConfigPlan2(_AcDb.ResultBuffer rb)
        {
            try
            {
                TheConfiguration.Loaded = false;

                GetArgs(rb);

                using (ConfigForm frm = new ConfigForm(_FileName))
                {
                    _AcAp.Application.ShowModalDialog(frm);
                }
            }
            catch (System.Exception ex)
            {
                _AcAp.Application.ShowAlertDialog(string.Format(CultureInfo.CurrentCulture, "Fehler in ConfigPlan2 aufgetreten!\n{0}", ex.Message));
            }
            return(null);
        }
        static public _AcDb.ResultBuffer AcadEvalLisp(string arg)
        {
            IntPtr rb = IntPtr.Zero;

            acedEvaluateLisp(arg, out rb);
            if (rb != IntPtr.Zero)
            {
                try
                {
                    _AcDb.ResultBuffer rbb = _AcTrx.DisposableWrapper.Create(typeof(_AcDb.ResultBuffer), rb, true) as _AcDb.ResultBuffer;
                    return(rbb);
                }
                catch
                {
                    return(null);
                }
            }
            return(null);
        }
Beispiel #27
0
        public static _AcDb.ResultBuffer GetNonPlottableLayers(_AcDb.ResultBuffer rb)
        {
            List <string> layerNames = new List <string>();

            Globs.GetNonPlottableLayers(layerNames);

            if (layerNames.Count > 0)
            {
                _AcDb.ResultBuffer rbRet = new _AcDb.ResultBuffer();
                foreach (var name in layerNames)
                {
                    rbRet.Add(new _AcDb.TypedValue((int)_AcBrx.LispDataType.Text, name));
                }
                return(rbRet);
            }
            else
            {
                return(null);
            }
        }
Beispiel #28
0
        private void AddPoints(AcDb.ObjectId idBorderParcel)
        {
            AcDb.ResultBuffer xData = new AcDb.ResultBuffer();
            int dxfCode;

            AcDb.TypedValue typedValue;

            dxfCode    = (int)AcDb.DxfCode.ExtendedDataRegAppName;
            typedValue = new AcDb.TypedValue(dxfCode, "Точки межі");
            xData.Add(typedValue);

            int iCurNumberPoint = 0;

            Dictionary <string, string> tags = new Dictionary <string, string>();

            foreach (AcGe.Point2d point in this.Parcel.Points)
            {
                iCurNumberPoint += 1;
                tags.Clear();
                tags.Add("NUMBER", "");
                AcDb.ObjectId idPoint = ServiceBlockElements.InsertBlock
                                        (
                    settingsDrawing.Plan.Point.NameBlock,
                    new AcGe.Point3d(point.X, point.Y, 0.0),
                    this.SettingsForm.ScaleDrawing,
                    0,
                    ServiceCAD.CreateLayer(settingsDrawing.Plan.Point.Layer),
                    tags
                                        );

                //dxfCode = (int)DxfCode.ExtendedDataHandle;
                dxfCode    = (int)AcDb.DxfCode.ExtendedDataAsciiString;
                typedValue = new AcDb.TypedValue(dxfCode, point.ToString());
                xData.Add(typedValue);
            }
            if (!idBorderParcel.Equals(AcDb.ObjectId.Null))
            {
                ServiceCAD.SetXData(idBorderParcel, xData);
            }
        }
Beispiel #29
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);
            }
        }
        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);
        }