Trebuchet 发表于 2022-7-5 16:24:09

Inserting dynamic block - sett

Hello everyone!
 
I've been trying to figure this out, but I'm stuck on an error I keep getting.I've been using code found here in this forum, but what was working for other doesn't seem to work for me.
 
I can insert the block, but after that, I get an error and the code seems to die and doesn't set the parameter I want.
 
Here's the code so far:

(defun C:tblk() (vl-load-com) (setq oattreq (getvar 'attreq)) (setvar 'attreq 0) (command "_insert" "DYN_GRID" "S" "1" "R" "0" PAUSE) (setvar 'attreq oattreq) (LM:setdynpropvalue ( (vlax-ename->vla-object entlast) "X_25mark" "100")));; Set Dynamic Block Property Value-Lee Mac;; Modifies the value of a Dynamic Block property (if present);; blk - VLA Dynamic Block Reference object;; prp - Dynamic Block property name (case-insensitive);; val - New value for property;; Returns: 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)   ))
 
The error I'm getting is:
 
Now, as best as I can trouble shoot it, the error is being caused here:

(LM:setdynpropvalue ( (vlax-ename->vla-object entlast) "X_25mark" "100"))
 
However, I've tried every permutation of writing that to get it to run, but it won't.
 
The goal of this is to be able to allow users to insert a dynamic block and at the same time set the X and Y of the grid (which is an X/Y array).
 
I thought this would be simple enough.The parameter "X_25mark" is the X direction, and for now I'm trying to hard code it at "100".However, in the future, I would like to ask the user to enter what X and Y they want for the grid.
 
Can anyone help get me back on track?
 
Thank you in advance!

Lee Mac 发表于 2022-7-5 17:31:28

(LM:setdynpropvalue (vlax-ename->vla-object (entlast)) "X_25mark" "100")
Assumes that your "X_25mark" dynamic block parameter requires a string value.
页: [1]
查看完整版本: Inserting dynamic block - sett