.NET

.NET

Reply
New Member
danielsu2013
Posts: 2
Registered: ‎04-05-2013
Message 1 of 3 (179 Views)
Accepted Solution

How to use SetSystemVariable setting coordinate values

179 Views, 2 Replies
04-05-2013 03:47 AM

Hi,

 

I have a problem setting sysvar like SNAPBASE, which requires 2d point or 3d point.

 

I always get wrong input for the following lines. can anybody help to take a look?

 double[] point = new double[2] {5,5};
            
            object value1 = point;
            Application.SetSystemVariable("SNAPBASE", value1);

 

what value should I give a 2d point or 3d point?

 

Please help.

The value of system varibale SNAPBASE in .NET API is a Point2d, not a Point3d, nor a double array.

 

This code works:

 

 [CommandMethod("SetSB")]
public static void SetSnapBase()
{
Document dwg = Application.DocumentManager.MdiActiveDocument;
Editor ed = dwg.Editor;
Point2d sBase = (Point2d)Application.GetSystemVariable("SNAPBASE");
ed.WriteMessage("SNAPBASE: X={0} Y={1}", sBase.X, sBase.Y);
Point2d newBase = new Point2d(2.0, 2.0);
Application.SetSystemVariable("SNAPBASE", newBase);
ed.WriteMessage("SNAPBASE: X={0} Y={1}", sBase.X, sBase.Y);
}

 

*Expert Elite*
norman.yuan
Posts: 1,062
Registered: ‎04-27-2009
Message 2 of 3 (160 Views)

Re: How to use SetSystemVariable setting coordinate values

04-05-2013 06:39 AM in reply to: danielsu2013

The value of system varibale SNAPBASE in .NET API is a Point2d, not a Point3d, nor a double array.

 

This code works:

 

        [CommandMethod("SetSB")]
        public static void SetSnapBase()
        {
            Document dwg = Application.DocumentManager.MdiActiveDocument;
            Editor ed = dwg.Editor;

            Point2d sBase = (Point2d)Application.GetSystemVariable("SNAPBASE");
            ed.WriteMessage("SNAPBASE: X={0} Y={1}", sBase.X, sBase.Y);

            Point2d newBase = new Point2d(2.0, 2.0);
            Application.SetSystemVariable("SNAPBASE", newBase);
            ed.WriteMessage("SNAPBASE: X={0} Y={1}", sBase.X, sBase.Y);
        }

 

New Member
danielsu2013
Posts: 2
Registered: ‎04-05-2013
Message 3 of 3 (123 Views)

Re: How to use SetSystemVariable setting coordinate values

04-07-2013 09:10 PM in reply to: norman.yuan

thanks very much.

it worked well though there's a typo at the last line that should be newbase.:smileyvery-happy:

 

ed.WriteMessage("SNAPBASE: X={0} Y={1}", sBase.X, sBase.Y);
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.