Parametric Blocks, colors and lines?

Hello, we really start to like Bricscad!

Is it possible to automate colors, lineweight and other general parameters within parametric blocks? So far we can only use geometric parameters.

In autocad we don't know if it's possible too, we use visibility-states for that, but that's a lot of work....

What we trying to do is making 2D fences for festivals. There are fences that can go open, have all kinds of materials/colors on it, emergency exits, etc... and there are a lot of them, we want to draw them in long rows and they have to connect to each other. And... we have to count them... (how many emergency exits? Orange fances? Black?
Where do we start with this? Is it possible?

Comments

  • ALANH
    edited February 2021

    You should post this in the Lisp section its not hard to have a fence section block and repeatedly place it along a line etc. If they are blocks then count them make a table of how many etc.

    If you make the fence block with internal objects on layer 0 they will adopt the color of the layer they are inserted on. So would have multiple layers EXIT, NORMAL, MEDICAL.

    Also no reason why not simple 3d so could do a 3d view of site.

    Wont go into now but dynamic blocks can drag an edge and will auto repeat a pattern.

    Post a dwg

    Ask moderator to move to lisp section.

  • Thank you Alanh!

    • Moderator, can you move this to the Lisp-section?
    • I've attached the dynamic block

    Placing along a line would be great, as long the fences can change state after placing.
    3D would be perfect, but it's not a must. Do you draw 3D and just watch from above to see 2D? Or are you mirroring a 2D and 3D drawing?
    Good idea to to use colored layers. Is it possible to change layers automatically based on fence options?

    I'am a little afraid that I ask to much... we are already happy with some good directions and Lisp examples...

  • Have a look at this you need to save the Multi radio buttons2.lsp as well.

    ; insert dynamic block and repeat along a line
    ; can choose visibility state on insert
    ; By AlanH March 2021 info@alanh.com.au

    ;; 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 LM:getdynpropallowedvalues ( blk prp )
    (setq prp (strcase prp))
    (vl-some '(lambda ( x ) (if (= prp (strcase (vla-get-propertyname x))) (vlax-get x 'allowedvalues)))
    (vlax-invoke blk 'getdynamicblockproperties)
    )
    )

    ; Thanks to Lee for dynamic block stuff

    (defun LM:setdynpropvalue ( blk prp val )
    (setq prp (strcase prp))
    (vl-some
    '(lambda ( x )
    (if (= prp (strcase (vla-get-propertyname x)))
    (progn
    (vla-put-value x (vlax-make-variant val (vlax-variant-type (vla-get-value x))))
    (cond (val) (t))
    )
    )
    )
    (vlax-invoke blk 'getdynamicblockproperties)
    )
    )
    ;; Set Dynamic Block Visibility State - Lee Mac
    ;; Sets the Visibility Parameter of a Dynamic Block (if present) to a specific value (if allowed)
    ;; blk - [vla] VLA Dynamic Block Reference object
    ;; val - [str] Visibility State Parameter value
    ;; Returns: [str] New value of Visibility Parameter, else nil

    (defun LM:SetVisibilityState ( blk val / vis )
    (if
    (and
    (setq vis (LM:getvisibilityparametername blk))
    (member (strcase val) (mapcar 'strcase (LM:getdynpropallowedvalues blk vis)))
    )
    (LM:setdynpropvalue blk vis val)
    )
    )
    ;; Get Visibility Parameter Name - Lee Mac
    ;; Returns the name of the Visibility Parameter of a Dynamic Block (if present)
    ;; blk - [vla] VLA Dynamic Block Reference object
    ;; Returns: [str] Name of Visibility Parameter, else nil

    (defun LM:getvisibilityparametername ( blk / vis )
    (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))
    (setq vis
    (vl-some
    '(lambda ( pair )
    (if
    (and
    (= 360 (car pair))
    (= "BLOCKVISIBILITYPARAMETER" (cdr (assoc 0 (entget (cdr pair)))))
    )
    (cdr pair)
    )
    )
    (dictsearch
    (vlax-vla-object->ename (vla-getextensiondictionary blk))
    "ACAD_ENHANCEDBLOCK"
    )
    )
    )
    )
    (cdr (assoc 301 (entget vis)))
    )
    )

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ; starts here

    (defun c:test ( / oldsnap blklen ent pt end start div )

    (setq oldsnap (getvar 'osmode))
    (setvar 'osmode 512)
    ; block length and name
    (setq blklen 3500.0 bname "bouwhek")

    (setq ent (entsel "\nPick line near start "))
    (setq pt (cadr ent))

    (setq start (getpropertyvalue (car ent) "startpoint"))
    (setq end (getpropertyvalue (car ent) "endpoint"))
    ; match end picked
    (setq d1 (distance start pt)
    d2 (distance end pt)
    )
    (if (> d1 d2)
    (progn
    (setq temp start)
    (setq start end)
    (setq end temp)
    )
    )
    ; how many
    (setq len (distance start end))
    (setq div (fix (/ len 3500.0)))

    ; need a alert here about remainder

    ; set ucs to line
    (command "UCS" "OB" pt)
    (command "UCS" "Origin" (trans start 0 1))

    (setvar 'osmode 0)

    (command "-insert" "bouwhek" "0,0,0" 1.0 0.0)
    ; set visibilty state
    ; needs Multi radio buttons to work

    (setq blk (vlax-ename->vla-object (entlast)))
    (setq visval (LM:getvisibilityparametername blk ))
    (setq winlst (LM:getdynpropallowedvalues blk visval))
    (setq winlst (cons "Please Choose" winlst))
    (if (not AH:Butts2)(load "Multi Radio buttons2.lsp"))
    (if (not AHbut)(setq AHbut 1))
    (setq ans(ah:butts2 1 "v" 2 winlst))
    (LM:SetVisibilityState blk ans)
    ; copy block
    (repeat (- div 1)
    (command "copy" (entlast) "" "0,0" "3500.0,0" )
    )
    ; back to world
    (command "UCS" "W")
    ; reset osnap
    (setvar 'osmode oldsnap)
    (princ)
    )

  • Wow, this looks promising! Will look into this matter...

  • Good to hear. There is also Multi radio and multi toggles.

    You do though need to think about the remainder when a line has a leftover length.