.NET

Reply
Valued Contributor
RamanSBV
Posts: 88
Registered: ‎02-28-2012
Message 1 of 5 (218 Views)
Accepted Solution

Issue with INSNAME.

218 Views, 4 Replies
02-29-2012 08:36 PM

Hi,

 

We are unable to set the value for system variable "INSNAME" .

It is returning nothing after assigning values for this variable.

 

We are using below statement for setting the value.

Application.SetSystemVariable("INSNAME ", "test");

 string str1 = Application.GetSystemVariable("INSNAME").ToString(​);

 

str1 string value is "" (nothing). and value is not assigning to this variable.

(We are working in AutoCAD 2010. using programming language as .net 3.5).

 

Please give advice on this issue.

Try this test code:

using System;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;
// This line is not mandatory, but improves loading performances
[assembly: CommandClass(typeof(Rivilis.SetVar))]
namespace Rivilis
{
public class SetVar
{
[CommandMethod("SetInsName", CommandFlags.Modal)]
public void SetInsName()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Application.SetSystemVariable("INSNAME", "test");
string insname = Application.GetSystemVariable("INSNAME") as string;
if (insname != null) {
ed.WriteMessage("\nINSNAME = \"{0}\"", insname);
} else {
ed.WriteMessage("\nCan not get INSNAME!");
}
}
}
}

In what context you try to execute your's code?

Moderator
Alexander.Rivilis
Posts: 1,452
Registered: ‎04-09-2008
Message 2 of 5 (211 Views)

Re: Issue with INSNAME.

02-29-2012 10:32 PM in reply to: RamanSBV

Try this test code:

using System;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;
// This line is not mandatory, but improves loading performances
[assembly: CommandClass(typeof(Rivilis.SetVar))]
namespace Rivilis
{
    public class SetVar
    {
        [CommandMethod("SetInsName", CommandFlags.Modal)]
        public void SetInsName()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            Application.SetSystemVariable("INSNAME", "test");
            string insname = Application.GetSystemVariable("INSNAME") as string;
            if (insname != null) {
                ed.WriteMessage("\nINSNAME = \"{0}\"", insname);
            } else  {
                ed.WriteMessage("\nCan not get INSNAME!");
            }
        }
    }
}

In what context you try to execute your's code?


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Valued Contributor
RamanSBV
Posts: 88
Registered: ‎02-28-2012
Message 3 of 5 (207 Views)

Re: Issue with INSNAME.

03-01-2012 12:31 AM in reply to: Alexander.Rivilis

 

 

Thanks for your reply.

 

This is working fine in Main dll. which is attaching to autocad using netload.

But it is not working in reference dll to main dll.

 

Actually I am using above command with followed by  "Insert" Command.

 

Please advise on this

Moderator
Alexander.Rivilis
Posts: 1,452
Registered: ‎04-09-2008
Message 4 of 5 (202 Views)

Re: Issue with INSNAME.

03-01-2012 01:12 AM in reply to: RamanSBV

RamanSBV wrote:

... But it is not working in reference dll to main dll...


I did not understand what do you mean. Is that dll running in another thread?


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Valued Contributor
RamanSBV
Posts: 88
Registered: ‎02-28-2012
Message 5 of 5 (200 Views)

Re: Issue with INSNAME.

03-01-2012 01:16 AM in reply to: Alexander.Rivilis

 

 

While loading .net dlls into Autocad,  we will refer one dll (Main dll).

 This code is working fine in that dll.

 

Main dll will refer other dlls for UI layer and Business Layer. Right.

 

In those dll, this code is not working.

 

 

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.