• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

make an active layer from visual basic (not vba)

  • Thread starter Thread starter geogiac
  • Start date Start date

geogiac

Guest
Hi...I try to do something very simple from visual basic (not vba) on autocad.. i.e. make a layer active........... .
for precision ..with this line of code ...

thisdrawing.activelayer = thisdrawing.layers("0")

I can in the autocad internal editor to make the layer "02 active............
.....I can't write the same on an external visual basic application.........

what I managed to do is


acad = getobject(, "autocad.application")
dim pippo as object

acad.activedocument.layers.item(0)

acad.activedocument.activelayer= pippo


I've always been wrong.... .

Help me!!? ? ?
 
non ho ambiente vb per provare, ma prova con

set thisdrawing=acad.activedocument

e poi con

dim pippo as acadlayer


set pippo=thisdrawing.layers.item("0")

thisdrawing.activelayer= pippo
 
Unfortunately in vb there is no acadlayer object (me by mistake) but I modified your suggestions in this way:

(by the way ....vb.net banalized the set)


dim thisdrawing as an object
dim a as object

thisdrawing = acad.activedocument

a = thisdrawing.layers.item("0")

thisdrawing.activelayer = a


it always gives me error on the last line.....(you don't recognize the member...!!!? ? ? ! ! ! )

Thanks anyway for the answer!!
Hi.
 
Unfortunately in vb there is no acadlayer object (me by mistake) but I modified your suggestions in this way:

(by the way ....vb.net banalized the set)


dim thisdrawing as an object
dim a as object

thisdrawing = acad.activedocument

a = thisdrawing.layers.item("0")

thisdrawing.activelayer = a


it always gives me error on the last line.....(you don't recognize the member...!!!? ? ? ! ! ! )

Thanks anyway for the answer!!
Hi.
If you don't leave, I suggest you pass the always trusted thisdrawing.sendcommand "_-layer" & vbcr & "_c" & vbcr "0"
method little fine but that at the moment unlocks you the problem !!!
 
Thank you so much....with this method it works.....I still have to manage the problem but in the meantime I can work... thank you again
 
Thank you so much....with this method it works.....I still have to manage the problem but in the meantime I can work... thank you again
In fact it must be a temporary thing, but the error I think is in some missing definition.. the same vba messed up if you misdefined an object even simply between object and entity... .

but can't you upload vba library references in vb.net?
 
dim acaddwg as object
dim dwg as acadapplication

set acaddwg = getobject("", "autocad.drawing")
set dwg = acaddwg.application

dwg.visible = true

set layer = dwg.activedocument.layers(0)

ricordati che devi aggiungere nei riferimenti del vb la libreria:
autocad 2010 type library
se usi la versione 2010.

bye
 
Remember that you have to add in the vb references the library:
autocad 2010 type library
if you use the 2010 version.
Are vba and thatel vb.net bookcases comatible?
Can you upload references?

I didn't propose because I thought they weren't compatible....
 
that I know, perfectly compatible.

Hi.
Thanks... then this definitely changes the way to approach the .net... if you can use the vba libraries changes little way of programming right?

the problem however remains the same.... if they do not develop the libraries for new versions (as anticipated) this compatibility will be less and you will have to use the naked and raw .net to interface to autocad right?
 
an account is not to develop, another is to remove the vba form, it seems to me a gamble that not even the autodesk can afford.
Mr Bricscad, alternative cad, would become an even more valid alternative.
 
thanks to all for the answer.....I have not yet managed to find the solution to my problem ..........to make it worse I noticed that the workaround solution with send command only works with versions of autocad in Italian or English depending on the parameters turned!!!? ? ? ?

Well...
 
thanks to all for the answer.....I have not yet managed to find the solution to my problem ..........to make it worse I noticed that the workaround solution with send command only works with versions of autocad in Italian or English depending on the parameters turned!!!? ? ? ?

Well...
bhè this is a solvency problem always passing commands and parameters with the English version preceded by _

e.g. _layer & vbcr & _freeze (or _f) of course you have to know the commands in English but on the net you find everything.
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top