Message 1 of 21
pass a function to a function
Not applicable
07-25-2006
02:46 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have some lines of code that will iterate through all layouts in a drawing. I would like to make it into a function. I want to pass it to another function as a parameter so that function will run on each layout as it iterates through. Can you pass a function to another function? Can you pass a function with parameters of its own?
Here's the code. Thanks for help...
(setq IAcadDocument (vla-get-ActiveDocument (vlax-get-Acad-Object))
IAcadLayouts (vla-get-Layouts IAcadDocument)
IActiveLayout (vla-get-ActiveLayout IAcadDocument)
) ;_ setq
(vlax-for IAcadLayout IAcadLayouts
(if (not (wcmatch (vla-get-name IAcadLayout) "Model"))
(progn
(print (vla-get-Name IAcadLayout))
(vla-put-ActiveLayout IAcadDocument IAcadLayout)
;;;place function to be ran on each layout here;;
(MyFunc)
;(print (append (getvar "LIMMIN") (getvar "LIMMAX")))
)
)
) ;_ vlax-for
(vla-put-ActiveLayout IAcadDocument IActiveLayout)
;(textscr)
(princ)
Here's the code. Thanks for help...
(setq IAcadDocument (vla-get-ActiveDocument (vlax-get-Acad-Object))
IAcadLayouts (vla-get-Layouts IAcadDocument)
IActiveLayout (vla-get-ActiveLayout IAcadDocument)
) ;_ setq
(vlax-for IAcadLayout IAcadLayouts
(if (not (wcmatch (vla-get-name IAcadLayout) "Model"))
(progn
(print (vla-get-Name IAcadLayout))
(vla-put-ActiveLayout IAcadDocument IAcadLayout)
;;;place function to be ran on each layout here;;
(MyFunc)
;(print (append (getvar "LIMMIN") (getvar "LIMMAX")))
)
)
) ;_ vlax-for
(vla-put-ActiveLayout IAcadDocument IActiveLayout)
;(textscr)
(princ)