请尝试以下代码:
- (defun C:bpro(/ acsp adoc attvalue blkname blkobj prop_lst prop_names pt scl )
- (or adoc (setq adoc (vla-get-activedocument (vlax-get-acad-object))))
- (if (and (= (getvar "tilemode") 0) (= (getvar "cvport") 1))
- (setq acsp (vla-get-paperspace adoc))
- (setq acsp (vla-get-modelspace adoc))
- )
- (vla-startundomark adoc)
- (setq blkname "RECEPTACLE-DUPLEX-PLAY");<-- block name
- (if (not (tblsearch "block" blkname))(progn
- (alert "No such block in drawing, exit.")
- (exit)(princ))
- )
- (if (= 0 (setq scl (getvar "USERR1")))
- (setq scl (getreal "\nEnter User scale value: "))
- (setvar "USERR1" scl)
- )
- (while (setq pt (getpoint "\nPick insertion point (Or press Enter to Exit): "))
- (setq blkobj (vlax-invoke acsp 'insertblock pt blkname scl scl scl 0))
- (if (eq :vlax-true
- (vla-get-isdynamicblock
- (vla-item
- (vla-get-blocks
- (vla-get-activedocument (vlax-get-acad-object))
- )
- (vla-get-effectivename blkobj)
- )
- )
- )
- (progn
- (setq prop_names
- (mapcar 'vla-get-propertyname
- (setq
- prop_lst
- (vlax-safearray->list
- (vlax-variant-value
- (vla-getdynamicblockproperties blkobj)
- )
- )
- )
- )
- )
- (foreach prop prop_lst
- (if (and (eq "Angle1" (vla-get-propertyname prop))
- (member "Angle1" prop_names)
- )
- (vla-put-value
- prop
- (vlax-make-variant
- 0.0
- (vlax-variant-type (vla-get-value prop))
- )
- )
- )
- )
- )
- )
- (setq attvalue (getstring T "\nEnter attribute value for CCT : "))
- (foreach att (vlax-invoke blkobj 'getattributes)
- (if (eq "CCT" (vla-get-tagstring att))
- (vla-put-textstring att attvalue)
- )
- )
- )
- (princ)
- )
- (prompt "\nType BPRO to run the command")
- (prin1)
- (or (vl-load-com)
- (princ))
~'J'~ |