.NET

Reply
Contributor
dreamwtx
Posts: 12
Registered: ‎03-07-2012
Message 1 of 7 (387 Views)

How to change the layer to be on or off using c#.net ?

387 Views, 6 Replies
03-08-2012 12:30 AM

I hope that i can implement the function not using dll file in autocad. just carry out it  in  out of autocad  .

*Expert Elite*
Alfred.NESWADBA
Posts: 9,401
Registered: ‎06-29-2007
Message 2 of 7 (366 Views)

Re: How to change the layer to be on or off using c#.net ?

03-08-2012 10:15 AM in reply to: dreamwtx

Hi,

 

>> I hope that i can implement the function not using dll file in autocad

Not sure what you like to do now.

If you don't want to create a DLL but you want to develop in C# then you have to create an EXE and you have to use the COM-interface in such way:

ThisDrawing.Layers("myLayerName").LayerOn = false

 

Or you use VBA or LISP or SCRIPT or .... Or I'm fully wrong and didn't understand your question correctly, then sorry and please try to explain a little bit more detailed what you want to get.

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
*Expert Elite*
arcticad
Posts: 1,285
Registered: ‎06-21-2004
Message 3 of 7 (363 Views)

Re: How to change the layer to be on or off using c#.net ?

03-08-2012 10:52 AM in reply to: Alfred.NESWADBA

I posted some code over here just a few minutes ago.

 

http://forums.autodesk.com/t5/NET/how-to-access-AutoCAD-2012-from-Vb-net-Standard-Exe/td-p/3363237

---------------------------



(defun botsbuildbots() (botsbuildbots))
Contributor
dreamwtx
Posts: 12
Registered: ‎03-07-2012
Message 4 of 7 (349 Views)

Re: How to change the layer to be on or off using c#.net ?

03-08-2012 05:32 PM in reply to: Alfred.NESWADBA

i  want to develop exe using c# which can call autocad and carry out change of  the property (such as layer on or off ,names of layers).  for example, i have a dwg than contains a few layers ,i wanna to close a layers then saveas a dwg.

  in fact,i am not sure that if the functions can be implemented  using c# and not using dll file. this  is just my idea. i also  don't know this way is wrong or right.  i just borrow ideas from secondary development  for solidworks

Contributor
dreamwtx
Posts: 12
Registered: ‎03-07-2012
Message 5 of 7 (345 Views)

Re: How to change the layer to be on or off using c#.net ?

03-08-2012 06:18 PM in reply to: Alfred.NESWADBA

could  you give me more codes like "ThisDrawing.Layers("myLayerName").LayerOn = false"?

 

 

 

 

 

alfred.neswadba wrote:

Hi,

 

>> I hope that i can implement the function not using dll file in autocad

Not sure what you like to do now.

If you don't want to create a DLL but you want to develop in C# then you have to create an EXE and you have to use the COM-interface in such way:

ThisDrawing.Layers("myLayerName").LayerOn = false

 

Or you use VBA or LISP or SCRIPT or .... Or I'm fully wrong and didn't understand your question correctly, then sorry and please try to explain a little bit more detailed what you want to get.

 

- alfred -


 

*Expert Elite*
Alfred.NESWADBA
Posts: 9,401
Registered: ‎06-29-2007
Message 6 of 7 (334 Views)

Re: How to change the layer to be on or off using c#.net ?

03-09-2012 12:08 AM in reply to: dreamwtx

Hi,

 

you got a link from articad for how to access AutoCAD (COM) from an exe.

 

Then take the document-object, within that you have a collection of Layers, search your layer (by key within the collection, I called it in the sample "myLayerName") and switch it off (property LayerOn)

There is not more code then the above line necessary to switch off a layer with a name you know.

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
*Expert Elite*
arcticad
Posts: 1,285
Registered: ‎06-21-2004
Message 7 of 7 (324 Views)

Re: How to change the layer to be on or off using c#.net ?

03-09-2012 06:35 AM in reply to: Alfred.NESWADBA

http://www.developerfusion.com/tools/convert/vb-to-csharp/

---------------------------



(defun botsbuildbots() (botsbuildbots))
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!