Beispiel #1
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 #2
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);
            }
        }
Beispiel #3
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 #4
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();
            }
        }
Beispiel #5
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();
            }
        }
        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)));
                }
            }
        }
Beispiel #8
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 #9
0
        public static void TestInvokeLisp()
        {
            _AcDb.ResultBuffer args = new _AcDb.ResultBuffer();
            int stat = 0;


            args.Add(new _AcDb.TypedValue(RTSTR, "getplan2config"));

            //args.Add(new TypedValue(RTSTR, "vlax-ldata-get"));
            //args.Add(new TypedValue(RTSTR, "AA_PLAN2"));
            //args.Add(new TypedValue(RTSTR, "ConfigFile"));

            //args.Add(new TypedValue(RTLONG, 100));
            //args.Add(new TypedValue(RTLONG, 200));

            _AcDb.ResultBuffer res = InvokeLisp(args, ref stat);
            if (stat == RTNORM && res != null)
            {
                PrintResbuf(res);
                res.Dispose();
            }
        }
Beispiel #10
0
        private _AcDb.ResultBuffer GetDwgNames(string excelFileName)
        {
            List <string> dwgNames = new List <string>();

            using (var excelizer = new Excelizer(excelFileName, Excelizer.Direction.Import))
            {
                var importedRows         = excelizer.Import();
                var perDwgName           = importedRows.GroupBy(x => x.DwgPath);
                _AcDb.ResultBuffer rbRet = new _AcDb.ResultBuffer();
                foreach (var pdn in perDwgName)
                {
                    string dwgName = pdn.Key;
                    dwgNames.Add(dwgName);
                    rbRet.Add(new _AcDb.TypedValue((int)_AcBrx.LispDataType.Text, dwgName));
                }

                var dwgString = string.Join(", ", dwgNames.Select(x => System.IO.Path.GetFileName(x)).ToArray());
                log.InfoFormat("\nDatei '{0}' enthält Informationen folgende dwgs: {1}", excelFileName, dwgString);

                return(rbRet);
            }
        }