Ejemplo n.º 1
0
        public void run()
        {
            _Ed.PromptStringOptions pStrOpts = new _Ed.PromptStringOptions("\nFIND: ");
            pStrOpts.AllowSpaces = true;
            _Ed.PromptResult pr = _c.ed.GetString(pStrOpts);
            if (pr.Status != _Ed.PromptStatus.OK)
            {
                return;
            }
            string find = pr.StringResult;

            pStrOpts             = new _Ed.PromptStringOptions("\nREPLACE: ");
            pStrOpts.AllowSpaces = true;
            pr = _c.ed.GetString(pStrOpts);
            if (pr.Status != _Ed.PromptStatus.OK)
            {
                return;
            }
            string replace = pr.StringResult;

            renameText(find, replace);
            renameBlockInside(find, replace);
            renameBlockFields(find, replace);
            renameLayout(find, replace);
        }
Ejemplo n.º 2
0
        private bool insertFormSide(_Ge.Point3d ptPos, double dir, double rotation)
        {
            _Ed.PromptStringOptions pStrOpts = new _Ed.PromptStringOptions("\nFormSide: ");
            pStrOpts.AllowSpaces = false;
            _Ed.PromptResult pStrRes = _c.ed.GetString(pStrOpts);
            string           result  = pStrRes.StringResult;

            if (pStrRes.Status == _Ed.PromptStatus.Cancel)
            {
                return(false);
            }

            _Ge.Point3d         insert = ptPos;
            _Db.AttachmentPoint a      = _Db.AttachmentPoint.BottomCenter;

            if (rotation == 0.0)
            {
                a = _Db.AttachmentPoint.BottomCenter;
                double newX = ptPos.X - (bigCircleOffset - bigCircleRadius) * dir / 2;
                double newY = ptPos.Y + textOffset;
                insert = new _Ge.Point3d(newX, newY, ptPos.Z);
            }
            else
            {
                a = _Db.AttachmentPoint.MiddleRight;
                double newX = ptPos.X - textOffset;
                double newY = ptPos.Y - (bigCircleOffset - bigCircleRadius) * dir / 2;
                insert = new _Ge.Point3d(newX, newY, ptPos.Z);
            }

            insertText(insert, a, result, 0);
            return(true);
        }
Ejemplo n.º 3
0
        static public void DynamicBlockProps()
        {
            _AcAp.Document doc = _AcAp.Application.DocumentManager.MdiActiveDocument;
            _AcDb.Database db  = doc.Database;
            _AcEd.Editor   ed  = doc.Editor;

            _AcEd.PromptStringOptions pso = new _AcEd.PromptStringOptions("\nEnter dynamic block name or enter to select: ");
            pso.AllowSpaces = true;
            _AcEd.PromptResult pr = ed.GetString(pso);

            if (pr.Status != _AcEd.PromptStatus.OK)
            {
                return;
            }

            _AcDb.Transaction tr = db.TransactionManager.StartTransaction();
            using (tr)
            {
                _AcDb.BlockReference br = null;
                // If a null string was entered allow entity selection
                if (pr.StringResult == "")
                {
                    // Select a block reference
                    _AcEd.PromptEntityOptions peo = new _AcEd.PromptEntityOptions("\nSelect dynamic block reference: ");
                    peo.SetRejectMessage("\nEntity is not a block.");
                    peo.AddAllowedClass(typeof(_AcDb.BlockReference), false);

                    _AcEd.PromptEntityResult per = ed.GetEntity(peo);
                    if (per.Status != _AcEd.PromptStatus.OK)
                    {
                        return;
                    }

                    // Access the selected block reference
                    br = tr.GetObject(per.ObjectId, _AcDb.OpenMode.ForRead) as _AcDb.BlockReference;
                }

                else
                {
                    // Otherwise we look up the block by name
                    _AcDb.BlockTable bt = tr.GetObject(db.BlockTableId, _AcDb.OpenMode.ForRead) as _AcDb.BlockTable;
                    if (!bt.Has(pr.StringResult))
                    {
                        ed.WriteMessage("\nBlock \"" + pr.StringResult + "\" does not exist.");
                        return;
                    }

                    // Create a new block reference referring to the block
                    br = new _AcDb.BlockReference(new _AcGe.Point3d(), bt[pr.StringResult]);
                }

                _AcDb.BlockTableRecord btr = (_AcDb.BlockTableRecord)tr.GetObject(br.DynamicBlockTableRecord, _AcDb.OpenMode.ForRead);

                // Call our function to display the block properties
                DisplayDynBlockProperties(ed, br, btr.Name);

                // Committing is cheaper than aborting
                tr.Commit();
            }
        }
Ejemplo n.º 4
0
        private static bool GetNewText(_AcEd.Editor ed)
        {
            var prompt = new _AcEd.PromptStringOptions("\nNeuer Text: ");

            prompt.AllowSpaces = true;
            var prefixUserRes = ed.GetString(prompt);

            if (prefixUserRes.Status != _AcEd.PromptStatus.OK)
            {
                return(false);
            }
            _NewText = prefixUserRes.StringResult;
            return(true);
        }
Ejemplo n.º 5
0
        private string promptGetMaterial()
        {
            string materjal = "K500C-T";

            _Ed.PromptStringOptions promptOptions2 = new _Ed.PromptStringOptions("");
            promptOptions2.Message      = "\nArmatuuri teras: ";
            promptOptions2.DefaultValue = "K500C-T";
            _Ed.PromptResult promptResult2 = _c.ed.GetString(promptOptions2);

            if (promptResult2.Status == _Ed.PromptStatus.OK)
            {
                materjal = promptResult2.StringResult;
            }

            return(materjal);
        }
Ejemplo n.º 6
0
        private static bool GetOldText(_AcEd.Editor ed)
        {
            var prompt = new _AcEd.PromptStringOptions("\nZu ersetzender Text: ");

            prompt.AllowSpaces = true;
            while (string.IsNullOrEmpty(_OldText))
            {
                var prefixUserRes = ed.GetString(prompt);
                if (prefixUserRes.Status != _AcEd.PromptStatus.OK)
                {
                    return(false);
                }
                _OldText = prefixUserRes.StringResult;
            }
            return(true);
        }
Ejemplo n.º 7
0
        private bool insertNumber(_Ge.Point3d center, double rotation)
        {
            _Ed.PromptStringOptions pStrOpts = new _Ed.PromptStringOptions("\nNumber: ");
            pStrOpts.AllowSpaces = false;
            _Ed.PromptResult pStrRes = _c.ed.GetString(pStrOpts);
            string           result  = pStrRes.StringResult;

            if (pStrRes.Status == _Ed.PromptStatus.Cancel)
            {
                return(false);
            }

            _Db.AttachmentPoint a = _Db.AttachmentPoint.MiddleCenter;
            if (result.Length > 2)
            {
                _Ge.Point3d insert = center;

                a = _Db.AttachmentPoint.BottomRight;
                if (rotation == 0.0)
                {
                    double newX = center.X;
                    double newY = center.Y + textOffset;

                    insert = new _Ge.Point3d(newX, newY, center.Z);
                }
                else
                {
                    double newX = center.X - textOffset;
                    double newY = center.Y;

                    insert = new _Ge.Point3d(newX, newY, center.Z);
                }

                insertText(insert, a, result, rotation);
                return(false);
            }
            else
            {
                a = _Db.AttachmentPoint.MiddleCenter;
                insertText(center, a, result, 0.0);
                return(true);
            }
        }
Ejemplo n.º 8
0
        private static bool GetAttributeInfos(_AcEd.Editor ed, _AcAp.Document doc)
        {
            bool ok = false;

            _BlockName      = string.Empty;
            _AttributeName  = string.Empty;
            _AttributeValue = string.Empty;

            _AcEd.PromptNestedEntityResult per = ed.GetNestedEntity("\nZu änderndes Attribut wählen: ");

            if (per.Status == _AcEd.PromptStatus.OK)
            {
                using (var tr = doc.TransactionManager.StartTransaction())
                {
                    _AcDb.DBObject           obj = tr.GetObject(per.ObjectId, _AcDb.OpenMode.ForRead);
                    _AcDb.AttributeReference ar  = obj as _AcDb.AttributeReference;
                    if (ar != null && !ar.IsConstant)
                    {
                        _AcDb.BlockReference br = Plan2Ext.Globs.GetBlockFromItsSubentity(tr, per);
                        if (br != null)
                        {
                            ed.WriteMessage(string.Format(CultureInfo.CurrentCulture, "\nBlockname: {0}, Attributname: {1}.", Plan2Ext.Globs.GetBlockname(br, tr), ar.Tag));
                            var prompt = new _AcEd.PromptStringOptions("\nText in Attribut: ");
                            prompt.AllowSpaces = true;
                            var prefixUserRes = ed.GetString(prompt);
                            if (prefixUserRes.Status == _AcEd.PromptStatus.OK)
                            {
                                _AttributeValue = prefixUserRes.StringResult;
                                _AttributeName  = ar.Tag;
                                _BlockName      = Plan2Ext.Globs.GetBlockname(br, tr);

                                log.InfoFormat(CultureInfo.CurrentCulture, "Block: {0}, Attribut: {1}, Wert: '{2}'", _BlockName, _AttributeName, _AttributeValue);

                                ok = true;
                            }
                        }
                    }

                    tr.Commit();
                }
            }
            return(ok);
        }