- 积分
- 15341
- 明经币
- 个
- 注册时间
- 2002-2-4
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2003-3-21 08:10:00
|
显示全部楼层
VxGetMassProps - Returns a list of all mass properties of the object
;;; VxGetMassProps - Returns a list of all mass properties of the object
;;; -- Function VxGetMassProps
;;; Returns a list of all mass properties of the object.
;;; Copyright:
;;; 2001 MENZI ENGINEERING GmbH, Switzerland
;;; Arguments [Typ]:
;;; Obj = Object [VLA-OBJECT]
;;; Return [Typ]:
;;; > Mass properties '({Area Perimeter} {Mass Volume}
;;; Centroid MomentOfInertia
;;; ProductOfInertia RadiiOfGyration
;;; PrincipalMoments PrincipalDirections
;;; ) [LIST]
;;; Notes:
;;; - VxGetMassProps is designed to handle closed *Polylines,
;;; Regions and 3dsolids.
;;; - *Polylines and Regions returns 2D-lists in some parameters.
;;; - 2D-objects returns '({Area Perimeter}. . . . . . )
;;; - 3D-objects returns '({Mass Volume}. . . . . . )
;;; - Use a DocManagerReactor with a 'vlr-documentToBeDestroyed'-event
;;; to release the Gb:AcO and Gb:AcD objects at the end of a
;;; AutoCAD session - otherwise AutoCAD maybe crashes...
;;; USAGE: (VXGETMASSPROPS (vlax-ename->vla-object (car (entsel))))
;;; Modify By: 龍龍仔(LUCAS)
(defun VXGETMASSPROPS (OBJ / DELFLG RESLST TMPOBJ)
(setq GB:ACO (cond (GB:ACO)
((vlax-get-acad-object))
)
GB:ACD (cond (GB:ACD)
((vla-get-activedocument GB:ACO))
)
)
(if (member (vla-get-objectname OBJ)
'("AcDb2dPolyline" "AcDbPolyline")
)
(setq DELFLG t
TMPOBJ (vlax-safearray-get-element
(vlax-variant-value
(vla-addregion
(vla-get-modelspace GB:ACD)
(VXLISTTOARRAY vlax-vbobject (list OBJ))
)
)
0
)
)
(setq TMPOBJ OBJ)
)
(setq RESLST
(append
(list
(if (= (vla-get-objectname TMPOBJ) "AcDbRegion")
(progn
(list (vla-get-area TMPOBJ) (vla-get-perimeter TMPOBJ))
)
(list (vla-get-volume TMPOBJ) (vla-get-volume TMPOBJ))
)
(vlax-safearray->list
(vlax-variant-value (vla-get-centroid TMPOBJ))
)
(vlax-safearray->list
(vlax-variant-value (vla-get-momentofinertia TMPOBJ))
)
(if (= (vla-get-objectname TMPOBJ) "AcDbRegion")
(list (vla-get-productofinertia TMPOBJ))
(vlax-safearray->list
(vlax-variant-value
(vla-get-productofinertia TMPOBJ)
)
)
)
(vlax-safearray->list
(vlax-variant-value (vla-get-radiiofgyration TMPOBJ))
)
(vlax-safearray->list
(vlax-variant-value (vla-get-principalmoments TMPOBJ))
)
(vlax-safearray->list
(vlax-variant-value
(vla-get-principaldirections TMPOBJ)
)
)
)
)
)
(if DELFLG
(vla-delete TMPOBJ)
)
RESLST
)
; VxListToArray - Converts a list into an array
; -- Function VxListToArray
; Converts a list into an array.
; Copyright:
; 2000 MENZI ENGINEERING GmbH, Switzerland
; Arguments [Typ]:
; Lst = Standard list [LIST]
; Typ = Datatype [INT]
; Constants:
; - vlax-vbBoolean
; - vlax-vbDecimal *)
; - vlax-vbDouble
; - vlax-vbInteger
; - vlax-vbLong
; - vlax-vbObject
; - vlax-vbSingle
; - vlax-vbString
; - vlax-vbVariant
; Return [Typ]:
; > Array [VARIANT]
; Notes:
; *)Missing datatype in Visual LISP, initialize it in your Autoloader.
; - Can't be used for dotted pair or nested lists.
;
(defun VxListToArray (Typ Lst)
(vlax-make-variant
(vlax-safearray-fill
(vlax-make-safearray Typ (cons 0 (1- (length Lst))))
Lst
)
)
) |
|