本帖最后由 Gu_xl 于 2011-7-10 15:21 编辑
回复 pxt2001 的帖子
- ;;;(gxl-blk-att2init ent) 图块属性还原归位
- ;测试 (gxl-blk-att2init (car(entsel "\n选择图块")))
- (defun gxl-blk-att2init (ent / obj inspt
- Ownerobj atts objs
- attinspt rot xscale
- yscale zscale Alignment
- Backward ObliqueAngle Rotation
- TextAlignmentPoint
- TextGenerationFlag UpsideDown
- TrueColor
- )
- (if (= 'ename (type ent))
- (setq obj (vlax-ename->vla-object ent))
- (setq obj ent)
- )
- (setq Ownerobj (vla-Item (vla-get-blocks (vla-get-ActiveDocument(vlax-get-acad-object))) (vla-get-name obj)))
- (vlax-for a Ownerobj
- (setq objs (cons a objs))
- )
- (setq objs (reverse objs))
- (setq rot (vla-get-Rotation obj)
- xscale (vla-get-XScaleFactor obj)
- yscale (vla-get-yScaleFactor obj)
- zscale (vla-get-zScaleFactor obj)
- )
- (vla-put-Rotation obj 0)
- (vla-put-XScaleFactor obj 1)
- (vla-put-yScaleFactor obj 1)
- (vla-put-zScaleFactor obj 1)
- (setq atts (vla-GetAttributes obj)
- atts (safearray-value(vlax-variant-value atts))
- inspt (vlax-safearray->list(vlax-variant-value (vla-get-InsertionPoint obj)))
- )
- (if atts
- (progn
- (foreach att atts
- (vl-some '(lambda (x) (= (GXL-CATCHAPPLY vla-get-TagString (list (setq Ownerobj x))) (vla-get-TagString att))) objs)
- (setq attinspt (vlax-safearray->list (vlax-variant-value(vla-get-InsertionPoint Ownerobj))))
- (setq Alignment (vla-get-Alignment Ownerobj)
- Backward (vla-get-Backward Ownerobj)
- ObliqueAngle (vla-get-ObliqueAngle Ownerobj)
- Rotation (vla-get-Rotation Ownerobj)
- TextAlignmentPoint (vla-get-TextAlignmentPoint Ownerobj)
- TextGenerationFlag (vla-get-TextGenerationFlag Ownerobj)
- UpsideDown(vla-get-UpsideDown Ownerobj)
- TrueColor (vla-get-TrueColor Ownerobj)
- )
- (vla-put-Alignment att Alignment)
- (vla-put-Backward att Backward)
- (vla-put-ObliqueAngle att ObliqueAngle)
- (vla-put-Rotation att Rotation)
- (VL-CATCH-ALL-APPLY 'vla-put-TextGenerationFlag (list att TextGenerationFlag))
- (vla-put-Alignment att Alignment)
- (vla-put-UpsideDown att UpsideDown)
- (vla-put-TrueColor att TrueColor)
- (VL-CATCH-ALL-APPLY ‘vla-put-TextAlignmentPoint (list att (vlax-3d-point (mapcar '+ inspt (vlax-safearray->list (vlax-variant-value TextAlignmentPoint))))))
- )
- (vla-put-Rotation obj rot)
- (vla-put-XScaleFactor obj XScale)
- (vla-put-yScaleFactor obj yScale)
- (vla-put-zScaleFactor obj zScale)
- )
- )
- )
- (defun gxl-CatchApply (fun args / rtn )
- (if
- (not
- (vl-catch-all-error-p
- (setq rtn
- (vl-catch-all-apply (function fun) args)
- )
- )
- )
- rtn
- )
- )
- ;;;属性复位 编制 Gu_xl 2011.05.15
- (defun c:initatt ()
- (while (setq ss (ssget '((0 . "insert"))))
- (setq n (sslength ss))
- (repeat n
- (gxl-blk-att2init (ssname ss (setq n (1- n))))
- )
- )
- (princ)
- )
|