ActiveLayer, ActiveDocument?

ActiveLayer, ActiveDocument?

wesbird
Collaborator Collaborator
850 Views
2 Replies
Message 1 of 3

ActiveLayer, ActiveDocument?

wesbird
Collaborator
Collaborator
Hi,
In VBA, ActiveLayer = current layer, ActiveDocument = current document. in .Net, I can not find this function. Is the only way to get it through COM interop?


Thank you,
Wes
Windows 10 64 bit, AutoCAD (ACA, Map) 2023
0 Likes
851 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Try CLayer and MdiActiveDocument.
0 Likes
Message 3 of 3

Anonymous
Not applicable
try this:

Friend Function GetCurrent_Layer() As AcadLayer
Dim acadApp As AcadApplication
Dim acadDoc As AcadDocument
Dim ReturnLayer As AcadLayer

Try
acadApp = CType(Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication, AcadApplication)
acadApp.Visible = True
acadDoc = acadApp.ActiveDocument
acadDoc.Application.Visible = True
ReturnLayer = acadDoc.ActiveLayer

Catch ex As Exception
MessageBox.Show(ex.ToString)

End Try
Return (ReturnLayer)

End Function

wkr

Harold van Aarsen
0 Likes