Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Generated RotDim Object Displays Wrong Measurement

john-malulan
Participant

Generated RotDim Object Displays Wrong Measurement

john-malulan
Participant
Participant

Good day. I'm new to AutoCAD programming.

I'm trying to add rotated dimensions objects to the line I created programmatically.

I set the properties

XLine1Point = to the start X, Y of the line,

XLine2Point = to the end X, Y of the line.

 

But after generating the objects I have noticed that the RotDim Objects display wrong measurements. 

Please see attached image below. 

 

Red Dimension - Generated by the program

White Dimension - Manual

johnmalulan_0-1650857585630.png

johnmalulan_1-1650858073664.png

 

 

Here is my function to generate the RotDim Object. 

        public void CreateRotatedDimension(double xLine1_X, double xLine1_Y, double xLine2_X, double xLine2_Y, double dimLine_X, double dimLine_Y, string pos, string col)
        {
            // Get the current database
            Document acDoc = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;
            // Start a transaction
            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                // Open the Block table for read
                BlockTable acBlkTbl;
                acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
                                                   OpenMode.ForRead) as BlockTable;

                using (DocumentLock docLock = acDoc.LockDocument())
                {
                    // Open the Block table record Model space for write
                    BlockTableRecord acBlkTblRec;
                    acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
                                                          OpenMode.ForWrite) as BlockTableRecord;
                    // Create the rotated dimension
                    RotatedDimension acRotDim = new RotatedDimension();
                    acRotDim.SetDatabaseDefaults();
                    acRotDim.XLine1Point = new Point3d(xLine1_X, xLine1_Y, 0);
                    acRotDim.XLine2Point = new Point3d(xLine2_X, xLine2_Y, 0);
                    acRotDim.DimLinePoint = new Point3d(dimLine_X, dimLine_Y, 0);
                    acRotDim.DimensionStyle = acCurDb.Dimstyle;
                    if (col == "green")
                    {
                        acRotDim.Dimclrt = green;
                        acRotDim.Dimtxt = 320;
                    }
                    else
                    {
                        acRotDim.Dimclrt = red;
                        acRotDim.Dimtxt = 300;
                    }

                    if (pos == "V")
                    {
                        acRotDim.Rotation = 1.57;
                    }
                    else
                    {
                        acRotDim.Rotation = 3.14;
                    }
                    // Add the new object to Model space and the transaction
                    acBlkTblRec.AppendEntity(acRotDim);
                    acTrans.AddNewlyCreatedDBObject(acRotDim, true);
                    // Commit the changes and dispose of the transaction
                    acTrans.Commit();
                }
                    
            }
        }

 

Here is my code to call the function to generate the object. 

GenerateObjects obj = new GenerateObjects();
obj.CreateRotatedDimension(AA_C_Line_StartX, AA_C_Line_StartY, AA_C_Line_EndX, AA_C_Line_EndY, AA_C1_RotDimText_PosX, AA_C1_RotDimText_PosY, "H", "red");

obj.CreateRotatedDimension(AA_C_Line_StartX, AA_C_Line_StartY, AA_C_Line_EndX, AA_C_Line_EndY, AA_C2_RotDimText_PosX, AA_C2_RotDimText_PosY, "V", "red");

 

I already double-checked the values passed to the function. 

I also uploaded the sample drawing file. Please see attached file.

 

Your response is highly appreciated. Thanks. 

0 Likes
Reply
Accepted solutions (1)
252 Views
1 Reply
Reply (1)

Alexander.Rivilis
Mentor
Mentor
Accepted solution

PI is not equal 3.14

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

0 Likes