I have a block in my model, I would like to perform the following routine:
1. user actions the routine with [VISLIST]
2. user is prompted to select an existing block within the drawing (There are 2 versions of the block which I would like this to work with, and I will spread it to more blocks in the furture)
3. Creates a dialog box (EG 1000x2000px)
4. creates a list within the dialog, generated from the visibility states of the block which has been selected, each entry in the list has a radiobutton
5. creates a scrollbar on the dialog when the list is too long (number of entries/vis states is approaching 100 per block)
6. user selects from the list of radiobuttons
7. when the selection is made, a new copy of the block is created, and the user chooses a placement point for the block. scale 1 rotation 0.
8. cycle back to step 3, open dialog box and select option again with a new instance of the same block, repeat steps until user escapes routine
I have been using ai to generate the code, (I know...) and i can get various sections of the routine working, but not all together (either get an empty pop-up, or none, or the vis state wont change, etc)
I will attach my testing dwg, with the blocks, and I will attach my current code attempts. but feel free to rip me apart and start over if thats better...
Thanks very much for any help given.
Solved! Go to Solution.
Solved by thomasPure. Go to Solution.
Isn't it just as easy as manually now:
1. selecting the block
2. make copy in place
3. clicking the visiblity states grip to show the list on the screen for selection
4. then grab the grip of the block to move to new location?
Have what you want, can pick a block and get visibility states. Big thanks to lee-mac. This version is for less than about 18 items need to change code to open a list box as looks like you have more than 18. Look at lines 35-37 to change to list box.
; Change dynamic block properties when inserting look at properties available.
; By Alan H June 2022
;; Get Dynamic Block Property Allowed Values - Lee Mac
;; Returns the allowed values for a specific Dynamic Block property.
;; Set Dynamic Block Visibility State - Lee Mac
;; Sets the Visibility Parameter of a Dynamic Block (if present) to a specific value (if allowed)
;; Get Visibility Parameter Name - Lee Mac
;; Returns the name of the Visibility Parameter of a Dynamic Block (if present)
(defun insdynv (blkname / pt obj lst ans)
(if (not LM:setdynpropvalue )(load "Lee-mac Dynamic block get-put"))
(setq pt (getpoint "\nPick a pt for block "))
(command "-insert" blkname "s" 1.0 pt 0)
(setq obj (vlax-ename->vla-object (entlast)))
(setq visval (LM:getvisibilityparametername obj))
(setq lst (LM:getdynpropallowedvalues obj visval))
(setq lst (cons "Please choose" lst))
(if (not AH:Butts)(load "Multi Radio buttons.lsp"))
(if (not AHbut)(setq AHbut 1))
(setq ans (ah:butts 1 "v" lst))
(LM:SetVisibilityState obj ans)
(princ)
)
; set existing block visibilty
(defun insdyne (blkname / pt obj lst ans)
(if (not LM:setdynpropvalue )(load "Lee-mac Dynamic block get-put"))
(if (not AH:Butts)(load "Multi Radio buttons.lsp"))
(setq obj (vlax-ename->vla-object (car (entsel "\nPick a dynamic block "))))
(setq visval (LM:getvisibilityparametername obj))
(setq lst (LM:getdynpropallowedvalues obj visval))
(setq lst (cons "Please choose" lst))
(if (not AH:Butts)(load "Multi Radio buttons.lsp"))
(if (not AHbut)(setq AHbut 1))
(setq ans (ah:butts 1 "v" lst))
(LM:SetVisibilityState obj ans)
(princ)
)
Hi, thanks for the reply.
This looks like the Lee Mac solution I have tried before, however this may have an extra section that I didnt notice before, so I will give it a go and hopefully its a fix. Thanks!
Actually both methods would take about 4 mouse clicks. But my proposal would be a simple copy block lisp function. So run copy block lisp and first click do block selection using code to retrieve the insertion point as base point. Second click is new block location which is required for either lisp code. Third click is on the visibility states grip of new block. Fourth click is visibility states selection. The fourth click with a custom dialog box would be the OK button to dismiss the dialog.
Not sure about list box but in my Multi radio buttons.lsp I turned off the auto exit after pick a button, so not having the ok pick required.
Attached is the straight forward Copy Block lisp function cpb.lsp I mentioned in my last post which gives you the option to select any Block and will use the Insertion point as the Base point for the Copy. Then after selecting the Second point the new Block will be highlighted for you to pick on the Visibility States grip point to select a different Visibility States shown on the cursor menu. Then you can hit Enter to repeat the cpb.lsp function and since the last copied Block is still highlighted that will be the selected Block for the next Copy.
Heres the solution to my problem, thanks to all contributors.
I still have tweaks to make along the way, but hopefully this can help someone in the future.
to make it so that after you click the list it'll close the window without having to click OK, change this line of code from:
(action_tile "lst" "(setq lsec (atoi $value) )")
to:
(action_tile "lst" "(setq lsec (atoi $value) )(done_dialog)")
Not sure about the 2nd question. You'll have to provide a sample dynamic block with the 2 point placement.
Perhaps this link can provide a sample as solution:
https://www.cadtutor.net/forum/topic/66141-insert-dynamic-block-with-2-points/
As for the 1st question, replace these lines of code:
;; Prompt user for the new point to move the block
(setq pt (getpoint "\nSpecify point to place the block: "))
;; Move the block from the default point to the user-specified point
(vl-cmdf "_.move" blkent "" ipt pt) ;; Move from (20,20) to new point (pt)
With these:
(vl-cmdf "_.Move" blkent "" ipt) ; see block preview for placement
(while (= 1 (logand 1 (getvar 'CMDACTIVE))) (command pause)) ; while there's an active command pause
But the strange thing is that since you set the base point at (20,20), that is the source of the rubber band snap location. In order to see the block on the screen as you Move it into place, you'll have to exit the dialog, do a Zoom Extents. Then run CallTag again to see the block during the Move command.
Any reason for not setting the base point using the selected block?
Can't find what you're looking for? Ask the community or share your knowledge.