how to convert a VLA-OBJECT(lisp) into a VB object?

how to convert a VLA-OBJECT(lisp) into a VB object?

Anonymous
Not applicable
816 Views
16 Replies
Message 1 of 17

how to convert a VLA-OBJECT(lisp) into a VB object?

Anonymous
Not applicable
hi, everyone!

I have gotten an acad object by calling (vlax-get-acad-object) in an
AutoLisp program, now how could i convert it into a VB object and transfer
it to a vb function?

thx!
0 Likes
817 Views
16 Replies
Replies (16)
Message 2 of 17

dgorsman
Consultant
Consultant
Probably easiest is to pass the objects handle - just a string value, stable constant reference.
----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


0 Likes
Message 3 of 17

Anonymous
Not applicable
thank you.
but for the application(AutoCAD), the handle is nil, and it has a HWND, and
how could i convert a HWND into the AutoCAD.Application object?

дÈëÏûÏ¢ÐÂÎÅ:5651182@discussion.autodesk.com...
Probably easiest is to pass the objects handle - just a string value, stable
constant reference.
0 Likes
Message 4 of 17

jbooth
Advocate
Advocate
I am not familiar with lisp entities, but I would expect that you can pass the objectID to your VBA program and use the AcadDocument.ObjectIDtoObject() method.

I have been able to use the above method to get an ARX entity via COM. Don't ask why though; I'm not doing it any more 🙂
0 Likes
Message 5 of 17

kpblc2000
Advisor
Advisor
I think it means ThisDrawing.Application and nothing more.

Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям! | Do you find the posts helpful? "LIKE" these posts!
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.


Алексей Кулик aka kpblc | Aleksei Kulik aka kpblc Facebook | LinkedIn
autolisp.ru
Техническая поддержка программистов Autodesk в СНГ
Библиотека пользовательских lisp-функций | Custom Lisp-function library

0 Likes
Message 6 of 17

jbooth
Advocate
Advocate
Let me clarify my previous post.

Every autocad entity has an ObjectID property, which is used as a pointer to the object's information. This property can be converted to a vaue of datatype "long" (if it isn't already a long). You can then use this reference number to get the object via COM interop (ie: VBA) by using the command:

ThisDrawing.ObjectIDToObject(byval OldID as long)

This should work every time unless:
1. The referenced object is recently erased (and has the property: IsErased = True).
2. The entity does not belong to the active drawing (it belogs to another drawing in your application).

I don't know offhand if VLA-OBJECT will return erased entities, so I can't say for sure if you need to check for it or not.

JB
0 Likes
Message 7 of 17

dgorsman
Consultant
Consultant
Surely there is a better way to do this? You are referencing a running session of AutoCAD from an external VB application, right? Why not check for running instances of AutoCAD using the application and simply assign it to an object variable without running through LISP?
----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


0 Likes
Message 8 of 17

Anonymous
Not applicable
Thanks.

But the OBJECT I'm interested in is the AutoCAD.Application, it dose not
have an objectID or a handle.

дÈëÏûÏ¢ÐÂÎÅ:5652708@discussion.autodesk.com...
I am not familiar with lisp entities, but I would expect that you can pass
the objectID to your VBA program and use the AcadDocument.ObjectIDtoObject()
method.

I have been able to use the above method to get an ARX entity via COM. Don't
ask why though; I'm not doing it any more 🙂
0 Likes
Message 9 of 17

Anonymous
Not applicable
You means GetObject()?

What I warried about is that I'm not sure that this function can give me the
object which exactly I want, for example, if there are several sessions of
AutoCAD.
дÈëÏûÏ¢ÐÂÎÅ:5653233@discussion.autodesk.com...
Surely there is a better way to do this? You are referencing a running
session of AutoCAD from an external VB application, right? Why not check
for running instances of AutoCAD using the application and simply assign it
to an object variable without running through LISP?
0 Likes
Message 10 of 17

Anonymous
Not applicable
My function is inside a dll, not dvb.
Thank u
дÈëÏûÏ¢ÐÂÎÅ:5652755@discussion.autodesk.com...
I think it means ThisDrawing.Application and nothing more.
0 Likes
Message 11 of 17

Anonymous
Not applicable
Thank u.
It works for database-resident object, but I'm interested in the
AutoCAD.Application Object.
дÈëÏûÏ¢ÐÂÎÅ:5652836@discussion.autodesk.com...
Let me clarify my previous post.

Every autocad entity has an ObjectID property, which is used as a pointer to
the object's information. This property can be converted to a vaue of
datatype "long" (if it isn't already a long). You can then use this
reference number to get the object via COM interop (ie: VBA) by using the
command:

ThisDrawing.ObjectIDToObject(byval OldID as long)

This should work every time unless:
1. The referenced object is recently erased (and has the property: IsErased
= True).
2. The entity does not belong to the active drawing (it belogs to another
drawing in your application).

I don't know offhand if VLA-OBJECT will return erased entities, so I can't
say for sure if you need to check for it or not.

JB
0 Likes
Message 12 of 17

jbooth
Advocate
Advocate
GetObject() will only return the first instance it finds.

You can use the hwnd of the AutoCAD application, but you will need to import some windows API functions in order to get the exact application window you are looking for.

It's much more complicated than you would think.
0 Likes
Message 13 of 17

dgorsman
Consultant
Consultant
That shouldn't be a serious problem; I'm hard pressed to find a situation where more than one session of AutoCAD would (or even should) be running. If necessary, it can just be a program limitation.
----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


0 Likes
Message 14 of 17

Anonymous
Not applicable
Haven't LDT have you? It is still a 'one document per session' application
and I often have more than one (up to 3) sessions running at the same time.

wrote in message news:5654055@discussion.autodesk.com...
That shouldn't be a serious problem; I'm hard pressed to find a situation
where more than one session of AutoCAD would (or even should) be running.
If necessary, it can just be a program limitation.
0 Likes
Message 15 of 17

Anonymous
Not applicable
thank u.
дÈëÏûÏ¢ÐÂÎÅ:5653919@discussion.autodesk.com...
GetObject() will only return the first instance it finds.

You can use the hwnd of the AutoCAD application, but you will need to import
some windows API functions in order to get the exact application window you
are looking for.

It's much more complicated than you would think.
0 Likes
Message 16 of 17

dgorsman
Consultant
Consultant
*shudder*
----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


0 Likes
Message 17 of 17

Anonymous
Not applicable
🙂
thank you a lot.
дÈëÏûÏ¢ÐÂÎÅ:5654475@discussion.autodesk.com...
*shudder*
0 Likes