Programmatically change (C#) Changing Annotation scale of the Dynamic Block Objects

Programmatically change (C#) Changing Annotation scale of the Dynamic Block Objects

kmkxperia
Advocate Advocate
243 Views
0 Replies
Message 1 of 1

Programmatically change (C#) Changing Annotation scale of the Dynamic Block Objects

kmkxperia
Advocate
Advocate

I am placing the dynamic block on the current drawing, with annotation scale 1:10, now I change the Annotation scale to 1:100 and try to place the Dynamic object on current drawing but annotation scale of newly placed Object is still 1:10, but if I place it ,manually it takes proper scale

was using below code 

string scale = mod_DC_Main.str_DC_TempScale;
bref.ScaleFactors = new Scale3d(ptEnd.X, ptEnd.Y, ptEnd.Z);

Also wanted to know if this is the correct way of placing the custom Dynamic Blocks or there is other way?

 

 

 [CommandMethod("InsertDrawing")]
        public static void InsertDrawingtest() 
        {
            string comp = "C:\\autocad\\CP Autocad Macros\\CP AutoCAD Macros (C-Sharp)\\InstallerFiles\\CP_AcadMacros2k21\\AutoCAD\\v2021\\Misc\\Architectural Department\\S-Dtl Ref w Sect Dir.dwg";
            Document doc = acadApp.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            //Database db = HostApplicationServices.WorkingDatabase;
            Transaction tr = doc.TransactionManager.StartTransaction();
            // Prompt the user to specify the insertion points for the dynamic block instances
            PromptPointOptions ppo = new PromptPointOptions("\nSpecify insertion point for the dynamic block instances: ");
            ppo.AllowNone = true;
            PromptPointResult ppr;
            ppr = ed.GetPoint(ppo);
            Point3d ptEnd = ppr.Value;
            try
            {
                string dwgName = HostApplicationServices.Current.FindFile(comp, acadApp.DocumentManager.MdiActiveDocument.Database, FindFileHint.Default);
                Database db = new Database(false, false);
                db.ReadDwgFile(dwgName, System.IO.FileShare.Read, true, "");
                ObjectId BlkId;
                BlkId = doc.Database.Insert(dwgName, db, false);
                BlockTable bt = (BlockTable)tr.GetObject(doc.Database.BlockTableId, OpenMode.ForRead, true);
                BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
                BlockReference bref = new BlockReference(new Autodesk.AutoCAD.Geometry.Point3d(ptEnd.X, ptEnd.Y, ptEnd.Z), BlkId);
                //bref.TransformBy(Matrix3d.Scaling(1, new Point3d(ptEnd.X, ptEnd.Y, ptEnd.Z)));
                string scale = mod_DC_Main.str_DC_TempScale;
                bref.ScaleFactors = new Scale3d(ptEnd.X, ptEnd.Y, ptEnd.Z);
                //br.ScaleFactors = new Scale3d(xScale, yScale, 1.0);
                btr.AppendEntity(bref);
                tr.AddNewlyCreatedDBObject(bref, true);
                bref.ExplodeToOwnerSpace();

                ;

                bref.Erase();
                tr.Commit();
            }
            finally
            {
                tr.Dispose();
            }

 

 

 

kmkxperia_1-1684849652487.png

 


 

kmkxperia_0-1684849598588.png

 

0 Likes
244 Views
0 Replies
Replies (0)