SelectionSet VBA -> VLisp
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
SelectionSet VBA -> VLisp

 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA
Author Message
Maksim Sestic
Guest





Posted: Mon Dec 13, 2004 8:01 pm    Post subject: SelectionSet VBA -> VLisp Reply with quote

Dear Friends,

This is not strictly VBA-related question. I have problems generating AcadSelectionSet via VBA and then passing it to VLisp. Recently Jeff Mishler posted a code to this NG solving the same problem, but his solution is not "standardized" enough... My VLISP programming knowledge is _poor_ and I just can't convert VLA-Object (resulting SelectionSet) to Ename. Please see an example below...

A VBA function code snippet (Class named MyClass):

'This function passes a SelectionSet to VLISP
'Result is of type Object to avoid eventual type-conflicts
Public Function SelSetToLisp() As Object
Dim FilterType(0) As Integer
Dim FilterData(0) As Varian
'CreateSelectionSet creates SelSet neverthless if it exists or not
Set SelSetToLisp = CreateSelectionSet("TMP_SELSET")
FilterType(0) = 1001: FilterData(0) = "MYAPP"
'Here it is - ready to go (to VLISP)...
SelSetToLisp.Select acSelectionSetAll, , , FilterType, FilterData
End Function

VLISP usage of MyClass.SelSetToLisp() function:

(defun C:TEST ()
(vl-load-com)
;;Create instance of a Class object
(setq clsMyClass (vlax-create-object "MYDLL.MyClass"))
;;Store resulting SelectionSet to variable named ResultVBA
(setq ResultVBA (vlax-invoke-method clsMyClass 'SelSetToLisp))
;;TRICKY PART - Convert resulting VLA-object to Ename typed one
;;This is the line where program fails...
(setq ResultLSP (vlax-vla-object->ename ResultVBA))
)

All I want to get is Ename SelectionSet, just like SSGET does. Is there any example of how to convert the VLA-based SelectionSet to Ename-based one? I want to avoid (ssget "P") and calling a named SelSet from VLisp as it's name may vary (Jeff's approach).

Thanks,
Maksim Sestic

Back to top
Jeff Mishler
Guest





Posted: Wed Dec 15, 2004 1:37 am    Post subject: Re: SelectionSet VBA -> VLisp Reply with quote

OK, Maksim, it took me a few times reading this before it dawned on me what
you were trying to do. Sorry, just kind of dense lately.....

I think this is what you want:

(setq resultLSP (ssadd))
(vlax-for ent resultVBA
(ssadd (vlax-vla-object->ename ent) resultLSP)
)


--
Jeff
check out www.cadvault.com
"Maksim Sestic" <max@geoinova.com> wrote in message
news:41bdaef9_2@newsprd01...
Dear Friends,
<snip>
VLISP usage of MyClass.SelSetToLisp() function:

(defun C:TEST ()
(vl-load-com)
;;Create instance of a Class object
(setq clsMyClass (vlax-create-object "MYDLL.MyClass"))
;;Store resulting SelectionSet to variable named ResultVBA
(setq ResultVBA (vlax-invoke-method clsMyClass 'SelSetToLisp))
;;TRICKY PART - Convert resulting VLA-object to Ename typed one
;;This is the line where program fails...
(setq ResultLSP (vlax-vla-object->ename ResultVBA))
)

All I want to get is Ename SelectionSet, just like SSGET does. Is there any
example of how to convert the VLA-based SelectionSet to Ename-based one? I
want to avoid (ssget "P") and calling a named SelSet from VLisp as it's name
may vary (Jeff's approach).

Thanks,
Maksim Sestic
Back to top
Maksim Sestic
Guest





Posted: Wed Dec 15, 2004 1:55 pm    Post subject: Re: SelectionSet VBA -> VLisp Reply with quote

Thanks a lot, Jeff. It's my fault, anyway - I just realized my posting was
few Kbs in size... Hmm... Now I understand why my approach failed - Lisp
treats SelectionSet as a list of Enames, and can't be directly converted
from VLA-typed object via vlax-vla-object->ename.

Regards,
Maksim Sestic

"Jeff Mishler" <jeff_m@cadvault.com> wrote in message
news:41bf4f0b$1_3@newsprd01...
Quote:
OK, Maksim, it took me a few times reading this before it dawned on me
what
you were trying to do. Sorry, just kind of dense lately.....

I think this is what you want:

(setq resultLSP (ssadd))
(vlax-for ent resultVBA
(ssadd (vlax-vla-object->ename ent) resultLSP)
)


--
Jeff
check out www.cadvault.com
"Maksim Sestic" <max@geoinova.com> wrote in message
news:41bdaef9_2@newsprd01...
Dear Friends,
snip
VLISP usage of MyClass.SelSetToLisp() function:

(defun C:TEST ()
(vl-load-com)
;;Create instance of a Class object
(setq clsMyClass (vlax-create-object "MYDLL.MyClass"))
;;Store resulting SelectionSet to variable named ResultVBA
(setq ResultVBA (vlax-invoke-method clsMyClass 'SelSetToLisp))
;;TRICKY PART - Convert resulting VLA-object to Ename typed one
;;This is the line where program fails...
(setq ResultLSP (vlax-vla-object->ename ResultVBA))
)

All I want to get is Ename SelectionSet, just like SSGET does. Is there
any
example of how to convert the VLA-based SelectionSet to Ename-based one? I
want to avoid (ssget "P") and calling a named SelSet from VLisp as it's
name
may vary (Jeff's approach).

Thanks,
Maksim Sestic




Back to top
Terry W. Dotson
Guest





Posted: Wed Dec 15, 2004 7:16 pm    Post subject: Re: SelectionSet VBA -> VLisp Reply with quote

Maksim Sestic wrote:

Quote:
Now I understand why my approach failed - Lisp
treats SelectionSet as a list of Enames, and can't be directly converted
from VLA-typed object via vlax-vla-object->ename.

Have you considered making a temporary GROUP from VBA, then accessing
that from the Lisp side?

Terry
Back to top
Maksim Sestic
Guest





Posted: Wed Dec 15, 2004 8:50 pm    Post subject: Re: SelectionSet VBA -> VLisp Reply with quote

Terry,

Similar approach I was on was creating Variant of objects, actually a
replica of SelectionSet. In that case I might erase SelSet and free up some
memory. It might work slower (replica generation), but then I'll be able to
pass a Variant from VB to Lisp. The rest is up to VLisp's conversion from
VLA-variant objects group to Ename, and it works fine for me. I'm not sure
about ACAD's memory management (dis)abilities, presumebly it stores named
SelectionSets in memory until it's either swapped or ACAD sesstion gets
terminated.

ACAD's groups get written permanently and remain in DWG until Lisp-side user
decides to free them up. My VLispers are spoiled and might forget to perform
memory cleanup routine :-)

Regards,
Maksim Sestic

"Terry W. Dotson" <nospam@invalid.com> wrote in message
news:41c0475e$1_1@newsprd01...
Quote:
Maksim Sestic wrote:

Now I understand why my approach failed - Lisp
treats SelectionSet as a list of Enames, and can't be directly converted
from VLA-typed object via vlax-vla-object->ename.

Have you considered making a temporary GROUP from VBA, then accessing
that from the Lisp side?

Terry
Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Powered by phpBB