.NET

Reply
Contributor
prakasht66
Posts: 19
Registered: ‎05-11-2013
Message 1 of 3 (365 Views)

How to set variable in c#?

365 Views, 2 Replies
05-11-2013 02:19 AM

Hi im Currently working on c# automation.Since im using autocad interop im not able to understand the process of setting

variable in autocad..I have drawing files with different dimensionstyles used inside..I can filter the dimesion by selectionset.but the problem is im filterring through dimstyle name.Is there any dxf code for selecting all kind of dimension styles.So that it will be useful for me.Im completely new to to Autocad,.

 

But my problem is i need to apply one particular standard dimstyle to all my drawings..Can someone help how i could set variable to my new dimstyle(new).this is my code for setting variable ,but its not updating in my current document.

 

this is my code;

 

double a = Convert.ToDouble((acadDocument.GetVariable("DIMASZ")));

 

object b = Convert.ToDouble(2.5);

acadDocument.SetVariable(

"DIMASZ", b);

Contributor
prakasht66
Posts: 19
Registered: ‎05-11-2013
Message 2 of 3 (351 Views)

Re: How to set variable in c#?

05-11-2013 04:20 AM in reply to: prakasht66
I found the answer.i can simply set the variable by using this

acadDocument.Setvariable("DIMASZ",1.5);

but is it possible to apply these properties to my newly created dimensionstyle. give me a suggestion...Thanks in advance

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

Re: How to set variable in c#?

05-11-2013 07:16 AM in reply to: prakasht66

Firstly, some comments not directly answers your question here, but I thought it is important for you to know, seeing your other post.

 

It is not important that you use C# or VB.NET to do your code. Rather it is very important for beginner to know which AutoCAD programming API is used. In this forum, (and most AutoCAD custom programmers are doing) it is ObjectARX .NET API.

 

With the few lines of code you showed here, obviously, you are using COM API, which is often the topic in the "Visual Basic Customization forum, even you use C#. It is OK to ask COM API question here, a long as you know what you are using.

 

Back to your question.

 

Setting "DIMxxxx" system variable does not change DimStyles defined in current document. It only create document overrides, which works with current ActiveDimStyle together to present dimension in the current drawing. If you want to persist the changes made through setting system variables "DIMxxxx", you need to call AcadDimStyle.CopyFrom() method with ThisDrawing as source, be it the active dimstyle, or a dimstyle you just created.

 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.