帮助文件例子
- (vl-load-com)
- (defun c:Example_SetXData()
- ;; This example creates a line and attaches extended data to that line.
- (setq acadObj (vlax-get-acad-object))
- (setq doc (vla-get-ActiveDocument acadObj))
-
- ;; Create the line
- (setq startPt (vlax-3d-point 1 1 0)
- endPt (vlax-3d-point 5 5 0))
- (setq modelSpace (vla-get-ModelSpace doc))
- (setq lineObj (vla-AddLine modelSpace startPt endPt))
- (vla-ZoomAll acadObj)
- ;; Initialize all the xdata values. Note that first data in the list should be
- ;; application name and first datatype code should be 1001
- (setq DataType (vlax-make-safearray vlax-vbInteger '(0 . 9)))
- (setq Data (vlax-make-safearray vlax-vbVariant '(0 . 9)))
- (vlax-safearray-put-element DataType 0 1001)
- (vlax-safearray-put-element Data 0 "Test_Application")
- (vlax-safearray-put-element DataType 1 1000)
- (vlax-safearray-put-element Data 1 "This is a test for xdata")
- ;; layer
- (vlax-safearray-put-element DataType 2 1003)
- (vlax-safearray-put-element Data 2 "0")
- ;; real
- (vlax-safearray-put-element DataType 3 1040)
- (vlax-safearray-put-element Data 3 1.23479137438413E+40)
- ;; distance
- (vlax-safearray-put-element DataType 4 1041)
- (vlax-safearray-put-element Data 4 1237324938)
-
- ;; 16 bit Integer
- (vlax-safearray-put-element DataType 5 1070)
- (vlax-safearray-put-element Data 5 32767)
- ;; 32 bit Integer
- (vlax-safearray-put-element DataType 6 1071)
- (vlax-safearray-put-element Data 6 32767)
- ;; scaleFactor
- (vlax-safearray-put-element DataType 7 1042)
- (vlax-safearray-put-element Data 7 10)
- ;; 3D point
- (setq reals3 (vlax-3d-point -2.95 100 -20))
- (vlax-safearray-put-element DataType 8 1010)
- (vlax-safearray-put-element Data 8 reals3)
-
- ;; world space position
- (setq worldPos (vlax-3d-point 4 400.99999999 2.798989))
- (vlax-safearray-put-element DataType 9 1011)
- (vlax-safearray-put-element Data 9 worldPos)
-
- ;; Attach the xdata to the line
- (vla-SetXData lineObj DataType Data)
-
- ;; Return the xdata for the line
- (vla-GetXData lineObj "" 'xtypeOut 'xdataOut)
- )
GETXDATA
- (vl-load-com)
- (defun c:Example_GetXData()
- ;; This example creates a line and attaches extended data to that line.
- (setq acadObj (vlax-get-acad-object))
- (setq doc (vla-get-ActiveDocument acadObj))
-
- ;; Create the line
- (setq startPt (vlax-3d-point 1 1 0)
- endPt (vlax-3d-point 5 5 0))
- (setq modelSpace (vla-get-ModelSpace doc))
- (setq lineObj (vla-AddLine modelSpace startPt endPt))
- (vla-ZoomAll acadObj)
- ;; Initialize all the xdata values. Note that first data in the list should be
- ;; application name and first datatype code should be 1001
- (setq DataType (vlax-make-safearray vlax-vbInteger '(0 . 9)))
- (setq Data (vlax-make-safearray vlax-vbVariant '(0 . 9)))
- (vlax-safearray-put-element DataType 0 1001)
- (vlax-safearray-put-element Data 0 "Test_Application")
- (vlax-safearray-put-element DataType 1 1000)
- (vlax-safearray-put-element Data 1 "This is a test for xdata")
- ;; layer
- (vlax-safearray-put-element DataType 2 1003)
- (vlax-safearray-put-element Data 2 "0")
- ;; real
- (vlax-safearray-put-element DataType 3 1040)
- (vlax-safearray-put-element Data 3 1.23479137438413E+40)
- ;; distance
- (vlax-safearray-put-element DataType 4 1041)
- (vlax-safearray-put-element Data 4 1237324938)
-
- ;; 16 bit Integer
- (vlax-safearray-put-element DataType 5 1070)
- (vlax-safearray-put-element Data 5 32767)
- ;; 32 bit Integer
- (vlax-safearray-put-element DataType 6 1071)
- (vlax-safearray-put-element Data 6 32767)
- ;; scaleFactor
- (vlax-safearray-put-element DataType 7 1042)
- (vlax-safearray-put-element Data 7 10)
- ;; 3D point
- (setq reals3 (vlax-3d-point -2.95 100 -20))
- (vlax-safearray-put-element DataType 8 1010)
- (vlax-safearray-put-element Data 8 reals3)
-
- ;; world space position
- (setq worldPos (vlax-3d-point 4 400.99999999 2.798989))
- (vlax-safearray-put-element DataType 9 1011)
- (vlax-safearray-put-element Data 9 worldPos)
-
- ;; Attach the xdata to the line
- (vla-SetXData lineObj DataType Data)
-
- ;; Return the xdata for the line
- (vla-GetXData lineObj "" 'xtypeOut 'xdataOut)
- )
|