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

Current Layer

4 REPLIES 4
Reply
Message 1 of 5
sapersing
359 Views, 4 Replies

Current Layer

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.
4 REPLIES 4
Message 2 of 5
NathTay
in reply to: sapersing

Don't use SendCommand.

Regards - Nathan
Message 3 of 5
sapersing
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?
Message 4 of 5
Anonymous
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
Message 5 of 5
sapersing
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.

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