Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Exit vlax-for statement...

9 REPLIES 9
Reply
Message 1 of 10
Anonymous
848 Views, 9 Replies

Exit vlax-for statement...

hi

is there a way to exit out of vlax-for (ie similiar to the VB/A Exit
For)... i'm using it in the following code
(vlax-for `mgMenuGroup (vla-get-menugroups (vlax-get-acad-object))
(if (= (vla-get-name `mgMenuGroup) `sMenuGroupName)
(setq `ReturnValue :vlax-true)
(setq `ReturnValue :vlax-false)
) ;if
) ;vlax-for

any help would be great

cheers

mark
9 REPLIES 9
Message 2 of 10
Anonymous
in reply to: Anonymous

No, but you can step through the collection and exit out like this:

(setq idx -1
mgMenuGroups (vla-get-menugroups (vlax-get-acad-object))
count (vla-get-count mgMenuGroups)
)
(while (< (setq idx (1+ idx)) count)
(setq mgMenuGroup (vla-item mgMenuGroups idx))
(if (= (vla-get-name `mgMenuGroup) `sMenuGroupName)
(progn
(setq `ReturnValue :vlax-true
count idx);;we found a match, exit out by setting count=idx
)
(setq `ReturnValue :vlax-false)
)
)

"Mark Dubbelaar" wrote in message
news:4942208@discussion.autodesk.com...
hi

is there a way to exit out of vlax-for (ie similiar to the VB/A Exit
For)... i'm using it in the following code
(vlax-for `mgMenuGroup (vla-get-menugroups (vlax-get-acad-object))
(if (= (vla-get-name `mgMenuGroup) `sMenuGroupName)
(setq `ReturnValue :vlax-true)
(setq `ReturnValue :vlax-false)
) ;if
) ;vlax-for

any help would be great

cheers

mark
Message 3 of 10
Anonymous
in reply to: Anonymous

Yes you can 🙂

Tony showed us a technique where you can use the
exit function wrapped in vl-catch-all-apply to stop
the vlax-for operation and also conceal that nasty
error message the exit function produces.

--
Autodesk Discussion Group Facilitator


"Jeff Mishler" wrote in message news:4942219@discussion.autodesk.com...
No, but you can step through the collection and exit out like this:
Message 4 of 10
Anonymous
in reply to: Anonymous

Couldn't find the thread were Tony demonstrated this
but this one shows it in use. http://tinyurl.com/ass6z


--
Autodesk Discussion Group Facilitator
Message 5 of 10
Anonymous
in reply to: Anonymous

Ya know, I thought I recalled seeing this but a search didn't come up with
anything so I figured I was just dreaming.......

Thanks for jogging my memory a bit.

Jeff

"Jason Piercey" wrote in message
news:4942234@discussion.autodesk.com...
Yes you can 🙂

Tony showed us a technique where you can use the
exit function wrapped in vl-catch-all-apply to stop
the vlax-for operation and also conceal that nasty
error message the exit function produces.

--
Autodesk Discussion Group Facilitator


"Jeff Mishler" wrote in message
news:4942219@discussion.autodesk.com...
No, but you can step through the collection and exit out like this:
Message 6 of 10
Anonymous
in reply to: Anonymous

Glad I could help. Think I've only got two functions
in my library that use the exit function, both wrapped
up like that. Comes in real handy at times.



"Jeff Mishler" wrote in message news:4942237@discussion.autodesk.com...
Ya know, I thought I recalled seeing this but a search didn't come up with
anything so I figured I was just dreaming.......

Thanks for jogging my memory a bit.

Jeff
Message 7 of 10
Anonymous
in reply to: Anonymous

If the intent of your code is to determine if a menugroup
exists you might consider using vla-item or menugroup
instead of vlax-for.

--
Autodesk Discussion Group Facilitator


"Mark Dubbelaar" wrote in message news:4942208@discussion.autodesk.com...
hi

is there a way to exit out of vlax-for (ie similiar to the VB/A Exit
For)... i'm using it in the following code
(vlax-for `mgMenuGroup (vla-get-menugroups (vlax-get-acad-object))
(if (= (vla-get-name `mgMenuGroup) `sMenuGroupName)
(setq `ReturnValue :vlax-true)
(setq `ReturnValue :vlax-false)
) ;if
) ;vlax-for

any help would be great

cheers

mark
Message 8 of 10
Anonymous
in reply to: Anonymous

As Jason pointed out, you may want to use someting like this:

(vl-catch-all-error-p
(vl-catch-all-apply
'(lambda ()
(vla-item
(vla-get-menugroups
(vlax-get-acad-object)
)
`sMenuGroupName
)
)
)
)

This will return true if menugroup is loaded, nil if not.

"Mark Dubbelaar" wrote in message
news:4942208@discussion.autodesk.com...
hi

is there a way to exit out of vlax-for (ie similiar to the VB/A Exit
For)... i'm using it in the following code
(vlax-for `mgMenuGroup (vla-get-menugroups (vlax-get-acad-object))
(if (= (vla-get-name `mgMenuGroup) `sMenuGroupName)
(setq `ReturnValue :vlax-true)
(setq `ReturnValue :vlax-false)
) ;if
) ;vlax-for

any help would be great

cheers

mark
Message 9 of 10
Anonymous
in reply to: Anonymous

Jeez, if I could only type what I actually think....

That will return T if the menugroup is NOT loaded, and nil if it IS.


"Jeff Mishler" wrote in message
news:4942284@discussion.autodesk.com...
As Jason pointed out, you may want to use someting like this:

(vl-catch-all-error-p
(vl-catch-all-apply
'(lambda ()
(vla-item
(vla-get-menugroups
(vlax-get-acad-object)
)
`sMenuGroupName
)
)
)
)

This will return true if menugroup is loaded, nil if not.

"Mark Dubbelaar" wrote in message
news:4942208@discussion.autodesk.com...
hi

is there a way to exit out of vlax-for (ie similiar to the VB/A Exit
For)... i'm using it in the following code
(vlax-for `mgMenuGroup (vla-get-menugroups (vlax-get-acad-object))
(if (= (vla-get-name `mgMenuGroup) `sMenuGroupName)
(setq `ReturnValue :vlax-true)
(setq `ReturnValue :vlax-false)
) ;if
) ;vlax-for

any help would be great

cheers

mark
Message 10 of 10
Anonymous
in reply to: Anonymous

thanks jeff / jason... got it working ok with the while loop, but will check
you the vl-catch-all-apply ... i guess theres many was to skin a lisp

thanks again

cheers

mark


"Mark Dubbelaar" wrote in message
news:4942208@discussion.autodesk.com...
hi

is there a way to exit out of vlax-for (ie similiar to the VB/A Exit
For)... i'm using it in the following code
(vlax-for `mgMenuGroup (vla-get-menugroups (vlax-get-acad-object))
(if (= (vla-get-name `mgMenuGroup) `sMenuGroupName)
(setq `ReturnValue :vlax-true)
(setq `ReturnValue :vlax-false)
) ;if
) ;vlax-for

any help would be great

cheers

mark

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost