Пример #1
0
        private IEnumerable SelectPrompt()
        {
            IEnumerable ids    = null;
            var         selOpt = new PromptSelectionOptions();

            selOpt.Keywords.Add("Table");
            var keys = selOpt.Keywords.GetDisplayString(true);

            selOpt.MessageForAdding  = "\nВыбор блоков парковок: " + keys;
            selOpt.MessageForRemoval = "\nИсключение блоков: " + keys;

            selOpt.KeywordInput += (o, e) =>
            {
                throw new ArgumentNullException();
            };

            var sel = Ed.GetSelection(selOpt);

            if (sel.Status == PromptStatus.OK)
            {
                ids = sel.Value.GetObjectIds();
            }
            else if (sel.Status != PromptStatus.Keyword)
            {
                throw new Exception(AcadLib.General.CanceledByUser);
            }
            return(ids);
        }
Пример #2
0
        private async Task <bool> InsertBlock(string name)
        {
            using (var tsv = new TemporarySystemVariables()
            {
            })
            {
                tsv.TEXTEVAL = true;

                try
                {
                    Ed.InitCommandVersion(2);
                    Application.PreTranslateMessage += Application_PreTranslateMessage;
                    await Ed.CommandAsync("_.-INSERT", name, Editor.PauseToken);

                    Application.PreTranslateMessage -= Application_PreTranslateMessage;
                    await Ed.CommandAsync(1);

                    while (Ed.IsDragging || Settings.Variables.CMDNAMES.ToUpper().IndexOf("INSERT", StringComparison.Ordinal) >= 0)
                    {
                        await Ed.CommandAsync(Editor.PauseToken);
                    }
                }
                catch (Autodesk.AutoCAD.Runtime.Exception ex)
                {
                    if (ex.ErrorStatus != ErrorStatus.UserBreak)
                    {
                        throw;
                    }
                    Application.PreTranslateMessage -= Application_PreTranslateMessage;
                    return(false);
                }
            }
            return(true);
        }
Пример #3
0
        public static void SpTop(Entity ent)
        {
            Autocad.Init();

            var sset  = SSGet();
            var table = new Specification();

            Action <BlockReference> ProcessBref = null;

            ProcessBref = (bref) => {
                List <BlockReference> innerBlocks = new List <BlockReference>();
                Record r = GetContent(bref, innerBlocks);
                if (r["block_name"].StringValue.StartsWith("__"))
                {
                    table.Add(r);
                    return;
                }
                if (!r["block_name"].StringValue.StartsWith("_"))
                {
                    table.Add(r);
                }
                foreach (BlockReference b in innerBlocks)
                {
                    ProcessBref(b);
                }
            };

            SSForeach <BlockReference>(sset, ProcessBref);

            var report = new DwgTableReport(table);

            report.Save();
            Ed.WriteMessage("OK");
        }
Пример #4
0
        public async void _INOUTBLK()
        {
            Settings.Variables.ATTDIA = false;
            PromptStringOptions pso = new PromptStringOptions("\nEnter BlockName")
            {
                AllowSpaces     = false,
                UseDefaultValue = true,
                DefaultValue    = _blockName
            };
            var pr = Ed.GetString(pso);

            if (pr.Status != PromptStatus.OK)
            {
                return;
            }
            _blockName = pr.StringResult.ToUpper();

            try
            {
                await InsertBlock(_blockName);
            }
            catch (Autodesk.AutoCAD.Runtime.Exception ex)
            {
                if (ex.ErrorStatus != ErrorStatus.UserBreak)
                {
                    throw;
                }
            }
        }
Пример #5
0
        /// <summary>
        /// Нумерация свай
        /// </summary>
        public void Numbering()
        {
            // Форма настроек нумерации свай - порядок нумерации, имя блока сваи, имя атрибута номера сваи.
            PileOptions = PileOptions.Load();
            Options     = new PileNumberingOptions();
            Options.LoadDefault();
            Options = Options.PromptOptions();

            // Выбор свай для нумерации
            var selblocks = Ed.SelectBlRefs("Выбор блоков свай для нумерации");

            // фильтр блоков свай
            var piles = PileFilter.Filter(selblocks, PileOptions, false);

            // Сброс положения атрибута номера сваи если задано в настройках
            ResetPos(ref piles);

            // Определения стороны сваи и проверка ее одинаковости
            Options.PileSide = GetPileSides(ref piles);

            // Проверка дубликатов
            AcadLib.Blocks.Dublicate.CheckDublicateBlocks.Check(piles.Select(p => p.IdBlRef));

            // Проверка сваи и расстояний между ними.
            CheckPiles(piles);

            // Сортировка
            var pilesSort = Sort(piles);

            // Перенумерация
            Num(pilesSort);
        }
Пример #6
0
        public void InoutblKx()
        {
            var pso = new PromptStringOptions("\nEnter BlockName")
            {
                AllowSpaces     = false,
                UseDefaultValue = true,
                DefaultValue    = _blockName
            };
            var pr = Ed.GetString(pso);

            if (pr.Status != PromptStatus.OK)
            {
                return;
            }
            _blockName = pr.StringResult.ToUpper();

            try
            {
                InoutblKxAsync(_blockName);
            }
            catch (Autodesk.AutoCAD.Runtime.Exception ex)
            {
                if (ex.ErrorStatus != ErrorStatus.UserBreak)
                {
                    throw;
                }
            }
        }
Пример #7
0
        public static void SpAllF(Entity ent)
        {
            Autocad.Init();

            var sset = SSGet();
            var spec = new Specification();

            Action <BlockReference> ProcessBref = null;

            ProcessBref = (bref) => {
                List <BlockReference> innerBlocks = new List <BlockReference>();
                Record r = GetContent(bref, innerBlocks);
                if (!r["block_name"].StringValue.StartsWith("_") && !r["art"].StringValue.StartsWith("REF"))
                {
                    spec.Add(r);
                }
                foreach (BlockReference b in innerBlocks)
                {
                    ProcessBref(b);
                }
            };

            SSForeach <BlockReference>(sset, ProcessBref);

            var report = new CsvReport(spec);

            report.Save();
            Ed.WriteMessage("OK");
        }
        private void DrawPoint(Point3d a)
        {
            DBPoint b = new DBPoint(a);

            Ed.WriteMessage("selamın aleyküm");
            AppendEntity(Db.BlockTableId, b);
        }
        public Alignment GetAlignment()
        {
            PromptEntityOptions opt = new PromptEntityOptions("\nSelect the Alignment:");

            opt.SetRejectMessage("\nOnly alignment");
            opt.AddAllowedClass(typeof(Alignment), true);
            PromptEntityResult res = Ed.GetEntity(opt);

            if (res.Status != PromptStatus.OK)
            {
                return(null);
            }
            ;
            using (Transaction ts = Dwg.TransactionManager.StartTransaction())
            {
                try
                {
                    Alignment al = ts.GetObject(res.ObjectId, OpenMode.ForRead) as Alignment;
                    return(al);
                }
                catch (System.Exception)
                {
                    throw;
                }
            }
        }
        public Profile GetProfile()
        {
            PromptEntityOptions peo = new PromptEntityOptions("\nSelect the profile view");

            peo.SetRejectMessage("\nOnly profile view");
            peo.AddAllowedClass(typeof(Profile), true);
            PromptEntityResult res = Ed.GetEntity(peo);

            if (res.Status != PromptStatus.OK)
            {
                return(null);
            }
            using (Transaction ts = Dwg.TransactionManager.StartTransaction())
            {
                try
                {
                    Profile prf = ts.GetObject(res.ObjectId, OpenMode.ForRead) as Profile;
                    return(prf);
                }
                catch (System.Exception)
                {
                    throw;
                }
            }
        }
        public SampleLine GetSampleLine()
        {
            PromptEntityOptions peo = new PromptEntityOptions("\nSelect the SampleLine");

            peo.SetRejectMessage("\nOnly SampleLine");
            peo.AddAllowedClass(typeof(SampleLine), true);
            PromptEntityResult res = Ed.GetEntity(peo);

            if (res.Status != PromptStatus.OK)
            {
                return(null);
            }
            using (Transaction ts = Dwg.TransactionManager.StartTransaction())
            {
                try
                {
                    SampleLine smpLine = ts.GetObject(res.ObjectId, OpenMode.ForRead) as SampleLine;
                    return(smpLine);
                }
                catch (System.Exception)
                {
                    throw;
                }
            }
        }
Пример #12
0
 public void LayerTableTrx()
 {
     using (Transaction trx = Db.TransactionManager.StartTransaction())
     {
         LayerTable lt = Db.LayerTable(trx);
         Ed.WriteLine(lt.ObjectId);
     }
 }
Пример #13
0
 public void DimStyleTableTrx()
 {
     using (Transaction trx = Db.TransactionManager.StartTransaction())
     {
         DimStyleTable dt = Db.DimStyleTable(trx);
         Ed.WriteLine(dt.ObjectId);
     }
 }
Пример #14
0
 public void BlockTableTrx()
 {
     using (Transaction trx = Db.TransactionManager.StartTransaction())
     {
         BlockTable bt = Db.BlockTable(trx);
         Ed.WriteLine(bt.ObjectId);
     }
 }
        public void Ali2pro()
        {
            Alignment selectedAli = GetAlignment();

            if (selectedAli != null)
            {
                ObjectIdCollection prfIds = selectedAli.GetProfileViewIds();

                try
                {
                    Boolean loopControl = true;
                    while (loopControl)
                    {
                        foreach (ObjectId item in prfIds)
                        {
                            using (Transaction ts = Application.DocumentManager.MdiActiveDocument.TransactionManager.StartTransaction())
                            {
                                PromptPointOptions pntOpt = new PromptPointOptions("\nSelect a point");
                                pntOpt.AllowNone = true;
                                pntOpt.Message   = "dogruSec";
                                PromptPointResult pnt = Ed.GetPoint("\nSelect the point");
                                if (pnt.Status != PromptStatus.OK)
                                {
                                    return;
                                }
                                ;
                                Double km    = 0;
                                Double ofset = 0;
                                double x     = 0;
                                double y     = 0;
                                selectedAli.StationOffset(pnt.Value.X, pnt.Value.Y, ref km, ref ofset);
                                ProfileView pv = ts.GetObject(item, OpenMode.ForRead) as ProfileView;

                                pv.FindXYAtStationAndElevation(km, pv.Location.Y, ref x, ref y);

                                Point3d p1 = new Point3d(x, pv.Location.Y, 0);
                                Point3d p2 = new Point3d(x, pv.Location.Y + pv.ElevationMax, 0);
                                Xline   xl = new Xline();
                                xl.BasePoint   = p1;
                                xl.SecondPoint = p2;
                                BlockTable acBlkTbl;
                                acBlkTbl = ts.GetObject(Db.BlockTableId, OpenMode.ForRead) as BlockTable;
                                BlockTableRecord acBlkTblRec;
                                acBlkTblRec = ts.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
                                acBlkTblRec.AppendEntity(xl);
                                ts.AddNewlyCreatedDBObject(xl, true);
                                ts.Commit();
                            }
                        }
                    }
                }
                catch (System.Exception)
                {
                    throw;
                }
            }
        }
Пример #16
0
 /// <summary>
 /// Generates the transaction request.
 /// </summary>
 internal virtual void GenerateRequest()
 {
     Logger.Instance.Log("PayPal.Payments.Transactions.BaseTransaction.GenerateRequest(): Entered", PayflowConstants.SEVERITY_DEBUG);
     try
     {
         mRequestBuffer = new StringBuilder();
         RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_TRXTYPE, mTrxType));
         RequestBuffer.Append(PayflowUtility.AppendToRequest(PayflowConstants.PARAM_VERBOSITY, mVerbosity));
         if (mExtData != null && mExtData.Count > 0)
         {
             foreach (ExtendData Ed in mExtData)
             {
                 if (Ed != null)
                 {
                     Ed.RequestBuffer = mRequestBuffer;
                     Ed.GenerateRequest();
                 }
             }
         }
         if (mTender != null)
         {
             mTender.RequestBuffer = mRequestBuffer;
             mTender.GenerateRequest();
         }
         if (mInvoice != null)
         {
             mInvoice.RequestBuffer = mRequestBuffer;
             mInvoice.GenerateRequest();
         }
         if (mUserInfo != null)
         {
             mUserInfo.RequestBuffer = mRequestBuffer;
             mUserInfo.GenerateRequest();
         }
         if (mUserItem != null)
         {
             mUserItem.RequestBuffer = mRequestBuffer;
             mUserItem.GenerateRequest();
         }
         if (mBuyerAuthStatus != null)
         {
             mBuyerAuthStatus.RequestBuffer = mRequestBuffer;
             mBuyerAuthStatus.GenerateRequest();
         }
         Logger.Instance.Log("PayPal.Payments.Transactions.BaseTransaction.GenerateRequest(): Exiting", PayflowConstants.SEVERITY_DEBUG);
     }
     catch (BaseException)
     {
         throw;
     }
     catch (Exception Ex)
     {
         TransactionException TE = new TransactionException(Ex);
         throw TE;
     }
 }
Пример #17
0
 private void InsertBlockX(string name)
 {
     using (var tsv = new TemporarySystemVariables()
     {
     })
     {
         Ed.InitCommandVersion(2);
         Ed.Command("_.-INSERT", name, Editor.PauseToken, 1);
     }
 }
Пример #18
0
        private static List <ObjectId> GetSelection()
        {
            var sel = Ed.SelectImplied();

            if (sel.Status == PromptStatus.OK)
            {
                return(sel.Value.GetObjectIds().ToList());
            }
            return(Ed.SelectBlRefs("Выбор блоков"));
        }
        /// <summary>
        /// Recepción de datos del puerto serial enviados por arduino
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            //-------------------------Recepción de datos del arduino------------------------------
            _bufferint = serialPort1.ReadLine();

            //-------------Convirtiendo valores recibidos a datos tipo double------------------

            bool valnum1 = double.TryParse(_bufferint, out _data1);

            //-------------------Muestreo de datos para filtrar errores de medición-------------

            if (valnum1)   // Validando que el dato recibido sea un número
            {
                _dataHcsr04 = _data1;
                ErrorIntegral(_dataHcsr04 * 0.017);
                _sumHcsr04 = _sumHcsr04 + _dataHcsr04;
                _contador++;
            }

            //--------------Promediando datos del muestreo y calculando distancias------------------

            if (_contador == 29)
            {
                _promHcsr04 = _sumHcsr04 / 30;
                _contador   = 0;
                _sumHcsr04  = 0;
                _sumTime    = 0;

                _distanceHcsr04 = _promHcsr04 * 0.017;
                ErrorProporcional(_distanceHcsr04);
                ErrorDerivativo(_distanceHcsr04);

                //-------------Mandando distancia sensada por el sensor al monitor------------------

                BufferContentHcsr04(Math.Round(_distanceHcsr04, 1).ToString());
                BufferOutEp(Ep.ToString());
                BufferOutEint(Ei.ToString());
                BufferOutEderiv(Ed.ToString());
                BufferOutPwm(_pwmPid.ToString());

                //-----------------Envio de datos al arduino y graficación---------------------------
                serialPort1_SenddataProportional(_distanceHcsr04);
                Updategraph(i++, _distanceHcsr04);
                serialPort1.DiscardInBuffer();

                //-----------------Añadiendo datos a lista para su ingreso al excel-------------------
                Posiciones.Add(_distanceHcsr04);
                Errores.Add(Ep);

                if (i > 100)
                {
                    i = 0;
                }
            }
        }
 public void GetBlockTableRecords()
 {
     using (Transaction trx = Db.TransactionManager.StartTransaction())
     {
         BlockTable bt     = Db.BlockTable();
         var        blocks = bt.GetBlockTableRecords();
         foreach (var blk in blocks)
         {
             Ed.WriteLine($"Contains {blk.GetObjectIds().Count()} this many entities in BlockTableRecord");
         }
     }
 }
        public void Deneme()
        {
            Ed.PointMonitor += OnMouseMove;

            PromptPointOptions pOpt = new PromptPointOptions("helleo");
            PromptPointResult  pRes = Ed.GetPoint(pOpt);

            if (pRes.Status == PromptStatus.Cancel)
            {
                Ed.PointMonitor -= OnMouseMove;
            }
        }
        public void GetBlockTableRecordsOpenForReadAndXrefBlocks()
        {
            using (Transaction trx = Db.TransactionManager.StartTransaction())
            {
                BlockTable bt     = Db.BlockTable();
                var        blocks = bt.GetBlockTableRecords(OpenMode.ForRead, SymbolTableRecordFilter.IncludeDependent);

                foreach (var blk in blocks)
                {
                    Ed.WriteLine($"Contains {blk.GetObjectIds().Count()} this many entities in BlockTableRecord");
                }
            }
        }
Пример #23
0
        internal override ActionResults Execute(Selection sel, params object[] args)
        {
            if (!Ed.Search.IsFocused)
            {
                Ed.Search.ShowSearch();
            }
            else
            {
                Ed.Focus();
            }

            return(ActionResults.Clean);
        }
Пример #24
0
        internal override ActionResults Execute(Selection sel, params object[] args)
        {
            var str = Clipboard.GetText();

            if (Ed.HasBeforePaste)
            {
                var ev = new TextEventArgs(str);
                Ed.OnBeforePaste(ev);
                str = ev.Text;
            }

            base.insertString = str.MakeCharacters();
            return(base.Execute(sel));
        }
        public string[] OpenFiles()
        {
            OpenFileDialog ofd = new OpenFileDialog("XML dosyasını seçiniz..", "xml", "xml", "dialog", OpenFileDialog.OpenFileDialogFlags.AllowMultiple);



            if (ofd.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return(null);
            }
            Ed.WriteMessage("\nFile selected was \"{0}\".",
                            ofd.Filename
                            );
            return(ofd.GetFilenames());
        }
        public Point3d GetPoint()
        {
            PromptPointOptions opt = new PromptPointOptions("Noktayı seçiniz..");
            PromptPointResult  res = Ed.GetPoint(opt);

            if (res.Status == PromptStatus.OK)
            {
                Point3d pnt = new Point3d(res.Value.X, res.Value.Y, res.Value.Z);
                return(pnt);
            }
            else
            {
                Point3d pnt = new Point3d(0, 0, 0);
                return(pnt);
            }
        }
Пример #27
0
 static bool EditorUI(Ed ed)
 {
     if (!ed.Exists())
     {
         return(true);
     }
     else
     {
         return(H(P(ed.Name()),
                  B(S.MakeSnippets, () => ed.GenUserSnippets(dry: false)),
                  ed.CanHideBuildDir() ?
                  Tg("Hide build dir", ed.HideBuildDir,
                     ed.IsBuildDirHidden) : true,
                  flex));
     }
 }
        public void Point2Sec()
        {
            SampleLine smpLine = GetSampleLine();
            SampleLineVertexCollection smpVertices = smpLine.Vertices;
            List <Point3d>             pntList     = new List <Point3d>();

            Autodesk.AutoCAD.DatabaseServices.Polyline pl = new Autodesk.AutoCAD.DatabaseServices.Polyline();
            foreach (SampleLineVertex item in smpVertices)
            {
                pntList.Add(item.Location);
            }
            Line l = new Line(pntList[0], pntList[2]);
            ObjectIdCollection sectionViewID = smpLine.GetSectionViewIds();
            Boolean            loopControl   = true;

            while (loopControl)
            {
                using (Transaction ts = Dwg.TransactionManager.StartTransaction())
                {
                    try
                    {
                        PromptPointResult pnt = Ed.GetPoint("\nSelect the point");
                        if (pnt.Status == PromptStatus.Cancel)
                        {
                            return;
                        }
                        Point3d     pntOnSampleLine = l.GetClosestPointTo(pnt.Value, false);
                        Double      dist            = Math.Sqrt(Math.Pow((pntList[0].X - pntOnSampleLine.X), 2) + Math.Pow(pntList[0].Y - pntOnSampleLine.Y, 2));
                        SectionView sectionView     = ts.GetObject(sectionViewID[0], OpenMode.ForRead) as SectionView;
                        Point3d     pntOnSec        = sectionView.Location;
                        Double      left            = sectionView.OffsetLeft;
                        Point3d     startPoint      = new Point3d(sectionView.Location.X + left, sectionView.Location.Y, sectionView.Location.Z);
                        Point3d     targetPoint     = new Point3d(startPoint.X + dist, startPoint.Y, startPoint.Z);
                        Point3d     targetPoint2    = new Point3d(targetPoint.X, targetPoint.Y - 5, targetPoint.Z);
                        Xline       xl = new Xline();
                        xl.BasePoint   = targetPoint;
                        xl.SecondPoint = targetPoint2;
                        AppendEntity(Db.BlockTableId, xl);
                        ts.Commit();
                    }
                    catch (System.Exception)
                    {
                        throw;
                    }
                }
            }
        }
Пример #29
0
 private async void InoutblKxAsync(string name)
 {
     try
     {
         InsertBlockX(name);
         var psr = Ed.SelectLast();
         if (psr.Status != PromptStatus.OK)
         {
             return;
         }
         await Ed.CommandAsync("_.EXPLODE", psr.Value);
     }
     catch (Autodesk.AutoCAD.Runtime.Exception ex)
     {
         if (ex.ErrorStatus != ErrorStatus.UserBreak)
         {
             throw;
         }
     }
 }
Пример #30
0
        internal override ActionResults Execute(Selection selection, params object[] args)
        {
            undoPos = selection.Start;
            redoSel = selection.Clone();

            if (!selection.IsEmpty)
            {
                @string = DeleteRangeCommand.DeleteRange(Ed, selection);
            }

            var indentKey = Ed.AffinityManager.GetAffinity(new Pos(undoPos.Line, 0)).GetIndentComponentKey(Ed);
            var pos       = InsertNewLine(Document, undoPos);

            selection.Clear(pos);

            var comp = indentKey != null?App.Catalog <IDentComponent>().GetComponent(indentKey) : null;

            indent = comp != null?comp.CalculateIndentation((IView)Ed.FindForm(), pos.Line) : 0;

            if (indent > 0)
            {
                if (pos.Line > 0)
                {
                    var ln = Document.Lines[pos.Line - 1];

                    if (ln.IsEmpty() && ln.Length > 0)
                    {
                        unindent = ln.ToList();
                        ln.RemoveRange(0, ln.Length);
                    }
                }

                var str = Ed.UseTabs ? new string('\t', indent / Ed.IndentSize)
                    : new string(' ', indent);
                Document.Lines[pos.Line].Insert(0, str.MakeCharacters());
                selection.Clear(new Pos(pos.Line, pos.Col + str.Length));
            }

            return(Change);
        }