.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to use SetSystemVariable setting coordinate values

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
danielsu2013
455 Views, 2 Replies

How to use SetSystemVariable setting coordinate values

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.

2 REPLIES 2
Message 2 of 3
norman.yuan
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);
        }

 

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 3
danielsu2013
in reply to: norman.yuan

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost