SelectionSet VBA -> VLisp

SelectionSet VBA -> VLisp

Anonymous
Not applicable
294 Views
4 Replies
Message 1 of 5

SelectionSet VBA -> VLisp

Anonymous
Not applicable
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
0 Likes
295 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
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" wrote in message news:41bdaef9_2@newsprd01... Dear Friends, 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
0 Likes
Message 3 of 5

Anonymous
Not applicable
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" wrote in message news:41bf4f0b$1_3@newsprd01... > 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" wrote in message > news:41bdaef9_2@newsprd01... > Dear Friends, > > 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 > > >
0 Likes
Message 4 of 5

Anonymous
Not applicable
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
0 Likes
Message 5 of 5

Anonymous
Not applicable
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" wrote in message news:41c0475e$1_1@newsprd01... > 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
0 Likes