TheyCallMeJohn Posted August 16, 2013 Share Posted August 16, 2013 Does anyone know a clean way to toggle a specified flip parameter using auto lisp visual lisp? I use the getdynprops, getdynpropvalue, putdynpropvalue [by Jeff Mishler based on code from Steve Doman, Herman Mayfarth and Tony Tanzillo] for most of my dynamic block changing needs but I can't get it they don't seem to work for the flip parameter. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 16, 2013 Share Posted August 16, 2013 Consider the following function: [color=GREEN];; Toggle Flip State - Lee Mac[/color] ([color=BLUE]defun[/color] toggleflipstate ( obj ) ([color=BLUE]if[/color] ([color=BLUE]and[/color] ([color=BLUE]=[/color] [color=MAROON]"AcDbBlockReference"[/color] ([color=BLUE]vla-get-objectname[/color] obj)) ([color=BLUE]=[/color] [color=BLUE]:vlax-true[/color] ([color=BLUE]vla-get-isdynamicblock[/color] obj)) ) ([color=BLUE]vl-some[/color] ([color=BLUE]function[/color] ([color=BLUE]lambda[/color] ( p ) ([color=BLUE]if[/color] ([color=BLUE]equal[/color] '(0 1) ([color=BLUE]vlax-get[/color] p 'allowedvalues)) [color=GREEN];; likely to be a flip parameter[/color] ([color=BLUE]vla-put-value[/color] p ([color=BLUE]vlax-make-variant[/color] ([color=BLUE]-[/color] 1 ([color=BLUE]vlax-get[/color] p 'value)) [color=BLUE]vlax-vbinteger[/color])) ) ) ) ([color=BLUE]vlax-invoke[/color] obj 'getdynamicblockproperties) ) ) ) Usage: (toggleflipstate [color=green]<VLA-Dynamic-Block-Reference-Object>[/color]) Example program: ([color=blue]defun[/color] c:flip ( [color=blue]/[/color] obj ) ([color=blue]if[/color] ([color=blue]setq[/color] obj ([color=blue]car[/color] ([color=blue]entsel[/color]))) (toggleflipstate ([color=blue]vlax-ename->vla-object[/color] obj)) ) ([color=blue]princ[/color]) ) ([color=blue]vl-load-com[/color]) ([color=blue]princ[/color]) Quote Link to comment Share on other sites More sharing options...
TheyCallMeJohn Posted August 16, 2013 Author Share Posted August 16, 2013 Lee Mac, I have multiple flips states. Is there a way to pass it a the name and the parameter I want to set it to? Some are accesible by the user and some are not as they are controlled by lookup parameters. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 16, 2013 Share Posted August 16, 2013 Lee Mac,I have multiple flips states. Is there a way to pass it a the name and the parameter I want to set it to? Some are accesible by the user and some are not as they are controlled by lookup parameters. Sure, in general you could use my Set Dynamic Property Value function. For your case: (LM:SetDynamicPropValue <VLA-Object> "UB_FLIP" 1) or: (LM:SetDynamicPropValue <VLA-Object> "UB_FLIP" 0) Quote Link to comment Share on other sites More sharing options...
chowter Posted June 25, 2015 Share Posted June 25, 2015 Hi, i have some problems with set flip parameters. I used yours "Set Dynamic Property Value" Code and: (LM:SetDynamicPropValue <VLA-Object> "Flip_state0" 1) (LM:SetDynamicPropValue <VLA-Object> "Flip_state1" 1) After running the script appeared error: Error: bad argument type: VLA-OBJECT nil My flip parameter names: Flip_state0 Flip_state1 My dynamic block name: F_MOD_DIP_SW_HORIZONTAL I need some assistance... Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 25, 2015 Share Posted June 25, 2015 The first argument must be a valid VLA-Object - see my earlier example program for how to supply a VLA-Object to a function. Quote Link to comment Share on other sites More sharing options...
BrianTFC Posted June 2, 2016 Share Posted June 2, 2016 Lee, I know this is an old thread but, is there a way to make the code to where you can flip multiple blocks by window selecting them? ([color=blue]defun[/color] c:flip ( [color=blue]/[/color] obj ) ([color=blue]if[/color] ([color=blue]setq[/color] obj ([color=blue]car[/color] ([color=blue]entsel[/color]))) (toggleflipstate ([color=blue]vlax-ename->vla-object[/color] obj)) ) ([color=blue]princ[/color]) ) ([color=blue]vl-load-com[/color]) ([color=blue]princ[/color]) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 2, 2016 Share Posted June 2, 2016 Lee,I know this is an old thread but, is there a way to make the code to where you can flip multiple blocks by window selecting them? Certainly - please try the following: (defun c:flip ( / i s ) (if (setq s (ssget "_:L" '((0 . "INSERT")))) (repeat (setq i (sslength s)) (LM:toggleflipstate (vlax-ename->vla-object (ssname s (setq i (1- i))))) ) ) (princ) ) ;; Toggle Dynamic Block Flip State - Lee Mac ;; Toggles the Flip parameter if present in a supplied Dynamic Block. ;; blk - [vla] VLA Dynamic Block Reference object ;; Return: [int] New Flip Parameter value (defun LM:toggleflipstate ( blk ) (vl-some '(lambda ( prp / rtn ) (if (equal '(0 1) (vlax-get prp 'allowedvalues)) (progn (vla-put-value prp (vlax-make-variant (setq rtn (- 1 (vlax-get prp 'value))) vlax-vbinteger)) rtn ) ) ) (vlax-invoke blk 'getdynamicblockproperties) ) ) (vl-load-com) (princ) Toggle Flip State function from here. Quote Link to comment Share on other sites More sharing options...
Louderjohn Posted June 2, 2016 Share Posted June 2, 2016 Lee, Does your Flip.lsp program flip only the first Flip parameter encountered? What if there are more than one flip parameters defined in the dynamic block? Quote Link to comment Share on other sites More sharing options...
BrianTFC Posted June 2, 2016 Share Posted June 2, 2016 Lee, Thank you so much!!!! Brian Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 2, 2016 Share Posted June 2, 2016 Lee,Does your Flip.lsp program flip only the first Flip parameter encountered? What if there are more than one flip parameters defined in the dynamic block? Currently yes - change vl-some to mapcar to toggle all Flip parameters held by the block. Lee, Thank you so much!!!! Brian You're welcome! Quote Link to comment Share on other sites More sharing options...
halam Posted June 2, 2016 Share Posted June 2, 2016 I like it and probably is a good reason to give blocks a flip parameter With more dynamic feature it fails unexpected. (tested only a little bit...) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.