.NET

.NET

Reply
Valued Contributor
GrzesiekGP
Posts: 67
Registered: ‎02-03-2012
Message 1 of 7 (380 Views)
Accepted Solution

Get coordinates for dimension's arrorheads.

380 Views, 6 Replies
07-15-2012 02:33 AM

Hello!

I'm writing function which will help user to offset dimension. After enter command, he select dimension and select point near one of dimension's arrowheads. Then I'm calculating new XLinePoint1 or XLinePoint2 and replacing original.

 

I have everything done. I thought ... The problem is when user firstly create AlignedDimension and after that he create RotatedDimension by using continous function. After that XLinePoint1 and XLinePoint2 are not parallel to the DimLinePoint (look at image).

 

Now I really don't have idea how to solve this problem.

 

Maybe someone know how can I get coordinates of points selected in red rectangles?

I know that one is specified as "dimension line defining point" but what about second? How can I get its coordinates?  Or maybe there is other way to get this point?

 

_Tharwat post the list code here:

http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Get-coordinates-for-dimension-s-arror...

 

Maybe someone will know how can do the same in C#.

 

Thanks.

Just a guess, perhaps problem is on how you create dimension in tour code,

you may want  also to lookup the  points from GripPoins void,

see example:

 [CommandMethod("aldim")]
public void testAlignedDim()
{
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
AlignedDimension rd = null;
using (Transaction trans = db.TransactionManager.StartTransaction())
{
try
{
using (BlockTable bt = trans.GetObject(db.BlockTableId, OpenMode.ForWrite) as BlockTable)
{
BlockTableRecord btr = trans.GetObject(db.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord;
Point3d p1 = new Point3d(0.0, 0.0, 0.0);
Point3d p2 = new Point3d(100.0, 100.0, 0.0);
Point3d p3 = new Point3d(0.0, 50.0, 0.0);
rd = new AlignedDimension(
p1,
p2,
p3,
"<>",
db.Dimstyle) as AlignedDimension;
ObjectId objId = btr.AppendEntity(rd);
trans.AddNewlyCreatedDBObject(rd, true);
}
trans.Commit();
ed.WriteMessage("\nSretch Points:\n");
Point3dCollection pts = new Point3dCollection();
rd.GetStretchPoints(pts);
string info = "\n";
foreach (Point3d p in pts)
{
info = info + string.Format("{0:f3}", p) + "\n";
}
ed.WriteMessage(info);
}
catch (System.Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}

 

Active Contributor
leaveAlone
Posts: 38
Registered: ‎02-25-2011
Message 2 of 7 (323 Views)

Re: Get coordinates for dimension's arrorheads.

07-25-2012 01:01 PM in reply to: GrzesiekGP

I am also interested to find out this in one of .Net languages??

ADN Support Specialist
fenton.webb
Posts: 352
Registered: ‎07-24-2007
Message 3 of 7 (306 Views)

Re: Get coordinates for dimension's arrorheads.

07-30-2012 04:04 PM in reply to: leaveAlone

Can you post the DWG file so I can see the data please?





Fenton Webb

Developer Technical Services

Autodesk Developer Network


Valued Contributor
GrzesiekGP
Posts: 67
Registered: ‎02-03-2012
Message 4 of 7 (270 Views)

Re: Get coordinates for dimension's arrorheads.

11-08-2012 03:25 AM in reply to: fenton.webb

Up^

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 5 of 7 (250 Views)

Re: Get coordinates for dimension's arrorheads.

11-08-2012 09:41 AM in reply to: GrzesiekGP

Just a guess, perhaps problem is on how you create dimension in tour code,

you may want  also to lookup the  points from GripPoins void,

see example:

    [CommandMethod("aldim")]
        public void testAlignedDim()
        {
            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            AlignedDimension rd = null; 

                using (Transaction trans = db.TransactionManager.StartTransaction())
                {
                    try
                    {

                        using (BlockTable bt = trans.GetObject(db.BlockTableId, OpenMode.ForWrite) as BlockTable)
                        {
                            BlockTableRecord btr = trans.GetObject(db.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord;

                            Point3d p1 = new Point3d(0.0, 0.0, 0.0);
                            Point3d p2 = new Point3d(100.0, 100.0, 0.0);
                            Point3d p3 = new Point3d(0.0, 50.0, 0.0);

                             rd = new AlignedDimension(
                                p1,
                                p2,
                                p3,
                                "<>",
                                db.Dimstyle) as AlignedDimension;
                            
                            ObjectId objId = btr.AppendEntity(rd);
                            trans.AddNewlyCreatedDBObject(rd, true);
                            
                        }

                        trans.Commit();
                        ed.WriteMessage("\nSretch Points:\n");
                        Point3dCollection pts = new Point3dCollection();
                        rd.GetStretchPoints(pts);
                        string info = "\n";
                        foreach (Point3d p in pts)
                        {
                            info = info + string.Format("{0:f3}", p) + "\n";
                        }
                        ed.WriteMessage(info);
                    }

                    catch (System.Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                }           
        }

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Valued Contributor
GrzesiekGP
Posts: 67
Registered: ‎02-03-2012
Message 6 of 7 (237 Views)

Re: Get coordinates for dimension's arrorheads.

11-08-2012 01:14 PM in reply to: Hallex

Thank you very much!

GetStretchPoints is that what I was looking for :smileyhappy:

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 7 of 7 (225 Views)

Re: Get coordinates for dimension's arrorheads.

11-08-2012 01:36 PM in reply to: GrzesiekGP

You're very welcome,

Cheers :smileyhappy:

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.