Jump to content

How to Check if Dynamic Block has Linear parameters


handasa

Recommended Posts

Hello

i need a way to check if a dynamic block has a linear parameter or Not BY autolisp.

i don't need the value itself.i just wanna check if it has the type of "linear parameter" or not

thanks in advance

image.png.ac93a19dc84c8f9a281c34d953d36643.png

Edited by handasa
Link to comment
Share on other sites

6 hours ago, ammobake said:

u would need to go into block editor, then parameters manager (command _PARAMETERS).

It would be on the list.

 

-ChriS

thank you ChriS.i want a way to check without using the bedit command.

Link to comment
Share on other sites

Here's a couple resources I found in a quick search.  That is if a Lisp is what you're after.  *whisper* - You didn't mention that part by the way. 😉

 

https://www.theswamp.org/index.php?topic=49681.0

 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/obtaining-dynamic-block-property-information-with-autolisp/td-p/5127510

Link to comment
Share on other sites

3 minutes ago, Magnum Z said:

This looks like it'll take time to understand, but this might be your best bet.

 

http://poleshchuk.spb.ru//cad/2009/tainypode.htm

Thanks Alot.i found a lisp written by Lee Mac and i modified it a little bit to check if the block has Stretch parameters or not.

it will return a list of the parameters names

 

(defun is-stretched (blk / plst)
    (if
        (and
            (vlax-property-available-p blk 'effectivename)
            (setq blk
                (vla-item
                    (vla-get-blocks (vla-get-document blk))
                    (vla-get-effectivename blk)
                )
            )
            (= :vlax-true (vla-get-isdynamicblock blk))
            (= :vlax-true (vla-get-hasextensiondictionary blk))
                (mapcar
                   '(lambda ( pair )
					(and
					(= 360 (car pair))
					(or
					(wcmatch (cdr (assoc 0 (entget (cdr pair)))) "BLOCKLINEARPARAMETER")
					(wcmatch (cdr (assoc 0 (entget (cdr pair)))) "BLOCKPOLARPARAMETER")
					)
					(setq plst (cons (cdr (assoc 305 (entget (cdr pair)))) plst))
					)
                    )
                    (dictsearch
                        (vlax-vla-object->ename (vla-getextensiondictionary blk))
                        "ACAD_ENHANCEDBLOCK"
                    )
                )
        )

    )
	
plst
)

 

Link to comment
Share on other sites

Perhaps:

(defun linearparam-p ( blk / ent )
    (and (setq ent (tblobjname "block" blk))
         (setq ent (cdr (assoc 360 (member '(102 . "{ACAD_XDICTIONARY") (entget (cdr (assoc 330 (entget ent))))))))
         (vl-some '(lambda ( x ) (and (= 360 (car x)) (= "BLOCKLINEARPARAMETER" (cdr (assoc 0 (entget (cdr x))))))) (dictsearch ent "acad_enhancedblock"))
    )
)
_$ (linearparam-p "dynamic_block")
T

 

Edited by Lee Mac
  • Like 1
Link to comment
Share on other sites

21 hours ago, Lee Mac said:

Perhaps:


(defun linearparam-p ( blk / ent )
    (and (setq ent (tblobjname "block" blk))
         (setq ent (cdr (assoc 360 (member '(102 . "{ACAD_XDICTIONARY") (entget (cdr (assoc 330 (entget ent))))))))
         (vl-some '(lambda ( x ) (and (= 360 (car x)) (= "BLOCKLINEARPARAMETER" (cdr (assoc 0 (entget (cdr x))))))) (dictsearch ent "acad_enhancedblock"))
    )
)

_$ (linearparam-p "dynamic_block")
T

 

thanks Lee.this did the trick.thanks alot

Link to comment
Share on other sites

  • 3 years later...

Hi,

 

It is possible to change this code to check if block contain a visibility parameter? I have tried to do it based on your last code, but with no luck..

 

 

Link to comment
Share on other sites

3 hours ago, A.Lach said:

It is possible to change this code to check if block contain a visibility parameter? I have tried to do it based on your last code, but with no luck..

 

Sure - 

(defun visibilityparam-p ( blk / ent )
    (and (setq ent (tblobjname "block" blk))
         (setq ent (cdr (assoc 360 (member '(102 . "{ACAD_XDICTIONARY") (entget (cdr (assoc 330 (entget ent))))))))
         (vl-some '(lambda ( x ) (and (= 360 (car x)) (= "BLOCKVISIBILITYPARAMETER" (cdr (assoc 0 (entget (cdr x))))))) (dictsearch ent "acad_enhancedblock"))
    )
)

 

Alternatively, you could use my Get Visibility Parameter Name function, or the function I posted here.

Link to comment
Share on other sites

Multi radio buttons.lspUsing Lee's great code Get visibility you can get all the values and pop them into a DCL so choose which one to use.

 

An example, you need to download Lee's dynamic block lisp and give it a name edit code to suit.

 

; 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)
)

 

Edited by BIGAL
Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...