Author Topic: setting dynamic properties  (Read 3083 times)

0 Members and 1 Guest are viewing this topic.

domenicomaria

  • Swamp Rat
  • Posts: 724
Re: setting dynamic properties
« Reply #15 on: April 05, 2022, 11:26:00 AM »
Text position is the distance from P1, along the direction P1 P2.
I assign to "text-position X" the value 1.0

Then I assign to "distance-p1-p2" the value 3.0.

This last thing means that I am stretching the dinamic block.

In this dynamic block there are 4 stretch actions.
Two of these one, move the text position.

And it is possible that the behaviour of the dynamic block
could change if i assign before or after a value to a properties

The Lee Mac LM:SETDYNPROPS routine
assigns the values to the properties
in the order returned by
(vlax-invoke ins-obj 'getdynamicBlockproperties)


And it is possible that this order
is not what we need in a particular situation !




Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: setting dynamic properties
« Reply #16 on: April 05, 2022, 11:59:20 AM »
You can use:
Code: [Select]
;; Set Dynamic Block Property Value  -  Lee Mac
;; Modifies the value of a Dynamic Block property (if present)
;; blk - [vla] VLA Dynamic Block Reference object
;; prp - [str] Dynamic Block property name (case-insensitive)
;; val - [any] New value for property
;; Returns: [any] New value if successful, else nil
(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)
    )
)
in the sequence needed...

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: setting dynamic properties
« Reply #17 on: April 06, 2022, 10:30:28 AM »
This is similar to LM:SETDYNPROPS but put values in sequence of PrpLst
Code: [Select]
; PrpLst ((<Property> . <Value>) (<Property2> . <Value2>)... )
(defun ALE_BlockDynamic_SetProps (BlkObj PrpLst / PrpVls PrpDat)
  (and
    BlkObj
    (setq PrpVls
      (mapcar
       '(lambda (LmbFor)
          (list (strcase (vla-get-propertyname LmbFor)) (vlax-get LmbFor 'value) LmbFor)
        )
        (vlax-invoke BlkObj 'getdynamicblockproperties)
      )
    )
    (foreach ForElm PrpLst
      (and
        (setq PrpDat (cdr (assoc (strcase (car ForElm)) PrpVls)))
        (not (eq (cdr ForElm) (car PrpDat)))
        (vla-put-value (cadr PrpDat) (vlax-make-variant (cdr ForElm) (vlax-variant-type (vla-get-value (cadr PrpDat)))))
      )
    )
  )
)