马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
本帖最后由 Free-Lancer 于 2013-8-22 08:23 编辑
- (defun c:chp_aire (/ AcDoc Space obj ins)
- (vl-load-com)
- (setq AcDoc (vla-get-ActiveDocument (vlax-get-acad-object))
- Space (if (= 1 (getvar "CVPORT"))
- (vla-get-PaperSpace AcDoc)
- (vla-get-ModelSpace AcDoc)
- )
- )
- (if
- (and
- (setq obj (car (entsel)))
- (member (cdr (assoc 0 (entget obj)))
- '("ARC" "CIRCLE" "ELLIPSE" "LWPOLYLINE" "REGION" "SPLINE")
- )
- (setq ins (getpoint "\nSpecify insertion point: "))
- )
- (vla-addMtext
- Space
- (vlax-3d-point ins)
- 0.0
- (strcat
- "%<\\AcObjProp.16.2 Object(%<\\_ObjId "
- (itoa (vla-get-ObjectID (vlax-ename->vla-object obj)))
- ">%).Area \\f "%lu2%pr2%ps[,m2]%ct8[1e-006]">%"
- )
- )
- )
- (princ)
- )
Another
- (defun C:Centroid (/ ent obj os pt area)
- ;; Select the region
- (setq ent (entsel "\nSelect region: "))
- ;; Is an object selected?
- (if ent
- (progn
- (setq ent_name (car ent))
- ;; Is it a region
- (if (= (cdr (assoc 0 (entget ent_name))) "REGION")
- (progn
- ;; Determine the centroid
- (setq obj (vlax-ename->vla-object ent_name))
- (setq pt (vlax-get obj "Centroid"))
- ;; Determine the area
- (setq area (vlax-get obj "Area"))
- (setq area (if (> area 144)
- (strcat (rtos (/ area 144) 2 2) " ft%%202")
- (strcat (rtos (/ area 1) 2 2) " in%%202")
- )
- )
- (setq scale (/ (getvar "DIMSCALE") 40.0))
- (setq os (getvar "osmode"))
- (setvar "osmode" 0)
- ;; Display coordinates
- (princ "\nCentroid found at: ")
- (princ (car pt))
- (princ ",")
- (princ (cadr pt))
- ;; Write the area
- (setq oid (vla-get-objectid obj))
- (if (vlax-property-available-p obj 'Area)
- (progn
- (setq
- txt (strcat "%<\\AcObjProp Object(%<\\_ObjId "
- (itoa oid)
- ">%).Area \\f "%pr2%lu2%ct4%qf1 sq ft>%"
- )
- )
- (command "text"
- "middle"
- pt
- (* (getvar "DIMSCALE") 0.09375)
- ""
- txt
- )
- )
- )
- )
- )
- )
- )
- (princ)
- )
|