.NET

Reply
Active Member
sapersing
Posts: 8
Registered: ‎09-03-2006
Message 1 of 5 (180 Views)

Current Layer

180 Views, 4 Replies
11-03-2006 05:09 PM
I am having an issue setting a layer to the active layer in vb.Net 2005.

We use lisp commands to thaw several layers at a time.
Ex:
(DEFUN C:TEST ()
(COMMAND "-LAYER" "T" "TEST1" "S" "TEST1" "F" "*" "T" "0, TEST1, TEST2" "")
)

I encounter my problem when trying to use the above command in .Net:

Dim acadApp As AcadApplication = CType(Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication, AcadApplication)

acadApp.ActiveDocument.SendCommand("TEST" & vbCr)

AutoCAD will show in the layer properties manager that TEST is the current layer.
However, if I do a query after the SendCommand line of code (Ex: MsgBox(acadApp.ActiveDocument.ActiveLayer.Name)), it tells me that the active layer is the 0 layer.

Anybody have any ideas?
Any help whatsoever will be greatly appreciated.
Distinguished Contributor
NathTay
Posts: 1,691
Registered: ‎12-15-2003
Message 2 of 5 (180 Views)

Re: Current Layer

11-05-2006 01:42 PM in reply to: sapersing
Don't use SendCommand.

Regards - Nathan
Active Member
sapersing
Posts: 8
Registered: ‎09-03-2006
Message 3 of 5 (180 Views)

Re: Current Layer

11-06-2006 05:43 AM in reply to: sapersing
Were you thinking along the lines of SendStringToExecute?
I tried the following but it didn't work either:

Dim acadApp As AcadApplication = CType(Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication, AcadApplication)
Application.DocumentManager.MdiActiveDocument.SendStringToExecute("Test" & vbCr, True, False, False)
Dim startPoint() As Double = {100,100,0}
Dim endPoint() As Double = {200,200,0}
acadApp.ActiveDocument.ModelSpace.AddLine(sp,ep)

Above puts the line on the wrong layer.
Is there another method you or anyone else can think of?
*James Buzbee
Message 4 of 5 (180 Views)

Re: Current Layer

11-06-2006 11:16 AM in reply to: sapersing
Sendcommand executes asynchronously - meaning you can't be sure if the
current layer is changed BEFORE the rest of the code is executed. Not sure
about SendStringtoExecute - but it looks like it based on your code. Why
aren't you setting the active layer property on the activedocument object?
Why use lisp for this?

jb
Active Member
sapersing
Posts: 8
Registered: ‎09-03-2006
Message 5 of 5 (180 Views)

Re: Current Layer

11-07-2006 05:23 PM in reply to: sapersing
I am using the lisp function because my company has around 250 of these little lisp functions in use.
Each of these freezes layers, thaws layers, sets linetypes, dimensions styles, snaps, and grid options.
I was hoping not to have to convert them to .Net but it looks like I am going to have to.
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.