I wrote this lisp to change Dynamic block properties using Lee subroutine.
this lisp insert a foundation block in CG of the column
I am facing 2 problems
- The changes not exact what i need when change value of variables W & L
For example change
(setq w 6400) ; Foundation Width
(setq l 6000) ; Foundation Length
To
(setq w 3400) ; Foundation Width
(setq l 3000) ; Foundation Length
- Start undo mark cases an error
(vla-StartUndoMark spc)
error is Error: ActiveX Server returned the error: unknown name: StartUndoMark
The code
(defun c:IFB ( / DIFL DIFW DOC HORDIM-01 HORDIM-02 L OBJ P1 P1X P1Y P2 P2X P2Y SPC VERDIM-01 VERDIM-02 W XDIF YDIF )
(vl-load-com)
(setq *acad (cond (*acad) ((vlax-get-acad-object))))
(setq doc (vla-get-ActiveDocument (setq *acad (vlax-get-Acad-Object)))
spc (if (zerop (vla-get-activespace doc)) (if (= (vla-get-mspace doc) :vlax-true) (vla-get-modelspace doc) (vla-get-paperspace doc)) (vla-get-modelspace doc)))
(if (vl-cmdf "_.-insert" "R:/SDC_LIBRARIES/CAD_LIBRARY/BLOCKS/S/Fx.dwg" "0,0,0" "1" "1" "0") ; inser Foundation block
(progn
;(vla-StartUndoMark spc)
(vl-cmdf "_.erase" "last" "")
(vl-cmdf "_.-purge" "blocks" "fx" "n")
(vl-cmdf "_.-DIMSTYLE" "Restore" "SDC_DIM")
(setq w 6400) ; Foundation Width
(setq l 6000) ; Foundation Length
(setq p1 (getpoint "\nPick Column CG"))
(setq p2 (getpoint "\nPick Axes Crossing point"))
(setq p1 (trans p1 1 0 ))
(setq p2 (trans p2 1 0 ))
(setq p1X (nth 0 p1))
(setq p1Y (nth 1 p1))
(setq p2X (nth 0 p2))
(setq p2Y (nth 1 p2))
(setq XDif (- p1X p2X))
(setq YDif (- p1Y p2Y))
(setq Difw (/ (- 6400 w) 2))
(setq Difl (/ (- 6000 l) 2))
(setq VerDim-01 (+ Difl (- (/ l 2) YDif)))
(setq VerDim-02 (+ Difl (- l VerDim-01)))
(setq HorDim-01 (+ Difw (- (/ w 2) XDif)))
(setq HorDim-02 (+ Difw (- w HorDim-01)))
(vl-catch-all-error-p (setq obj (vl-catch-all-apply
(function vla-InsertBlock)
(list spc (vlax-3D-point p1) "F00" 1.0 1.0 1.0 0))))
(vla-put-layer obj "S-FOND-EDGE")
(LM:setdynprops obj (list (cons "VerDim-01" VerDim-01)
(cons "VerDim-02" VerDim-02)
(cons "HorDim-01" HorDim-01)
(cons "HorDim-02" HorDim-02)
(cons "Width" w)
(cons "Length" l)
(cons "Visibility1" "WithDimentions" )))
;(vla-EndUndoMark spc)
)
(princ "\nUnable to Copy Block From Drawing.")
)
)
(defun *error* (msg)
(cond
((not msg))
((wcmatch (strcase msg) "*QUIT*,*CANCEL*"))
(T (princ (strcat "\nError: " msg)))
)
(redraw)
;(vla-EndUndoMark doc)
(princ)
) ;end error
;; Set Dynamic Block Properties - Lee Mac
;; Modifies values of Dynamic Block properties using a supplied association list.
;; blk - [vla] VLA Dynamic Block Reference object
;; lst - [lst] Association list of ((<Property> . <Value>) ... )
;; Returns: nil
(defun LM:setdynprops (blk lst / itm)
(setq lst (mapcar '(lambda (x) (cons (strcase (car x)) (cdr x))) lst))
(foreach x (vlax-invoke blk 'getdynamicblockproperties)
(if (setq itm (assoc (strcase (vla-get-propertyname x)) lst))
(vla-put-value
x
(vlax-make-variant
(cdr itm)
(vlax-variant-type (vla-get-value x))
)
)
)
)
) ; END DEFUN - LM:setdynprops
Thanks All