How to use SetSystemVariable setting coordinate values

How to use SetSystemVariable setting coordinate values

Anonymous
Not applicable
870 Views
2 Replies
Message 1 of 3

How to use SetSystemVariable setting coordinate values

Anonymous
Not applicable

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.

0 Likes
Accepted solutions (1)
871 Views
2 Replies
Replies (2)
Message 2 of 3

norman.yuan
Mentor
Mentor
Accepted solution

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);
        }

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 3

Anonymous
Not applicable

thanks very much.

it worked well though there's a typo at the last line that should be newbase.Smiley Very Happy

 

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