- UID
- 5244
- 积分
- 1648
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-5-18
- 最后登录
- 1970-1-1
|
发表于 2003-9-25 20:12:00
|
显示全部楼层
重新将代码整理在下面:
- [FONT=courier new]
- VxOleToAciCol - Converts a OLE- to a ACI-Colornumber
-
-
- ;
- ; -- Function VxOleToAciCol
- ; Converts a OLE- to a ACI-Colornumber
- ; Copyright:
- ; ?000 Jimmy Bergmark
- ; Arguments [Typ]:
- ; OleCol = OLE-Colornumber [INT]
- ; Return [Typ]:
- ; > ACI-Colornumber [INT]
- ; Notes:
- ; Thanx Jimmy B. for his excellent color converter.
- ;
- (defun VxOleToAciCol (OleCol)
- (vl-position
- (boole
- 1
- (vlax-variant-value (vlax-variant-change-type OleCol vlax-vbLong))
- 16777215
- )
- '(0 255 65535 65280 16776960
- 16711680 16711935 16777215 8421504 12632256
- 255 8421631 166 5460902 128
- 4210816 76 2500172 38 1250086
- 16639 8429567 10662 5466278 8320
- 4214912 4940 2502732 2598 1251366
- 33023 8437759 21414 5471398 16512
- 4219008 9804 2505036 4902 1252646
- 49151 8445951 31910 5476774 24704
- 4223104 14668 2507596 7462 1253670
- 65535 8454143 42662 5482150 32896
- 4227200 19532 2509900 9766 1254950
- 65471 8454111 42620 5482129 32864
- 4227184 19513 2509891 9757 1254945
- 65408 8454079 42579 5482108 32832
- 4227168 19494 2509881 9747 1254941
- 65344 8454047 42537 5482088 32800
- 4227152 19475 2509872 9738 1254936
- 65280 8454016 42496 5482067 32768
- 4227136 19456 2509862 9728 1254931
- 4259584 10485632 2729472 6858323 2129920
- 5275712 1264640 3165222 665088 1582611
- 8453888 12582784 5481984 8169043 4227072
- 6324288 2509824 3755046 1254912 1910291
- 12582656 14679936 8168960 9545299 6324224
- 7372864 3755008 4410406 1910272 2172435
- 16776960 16777088 10921472 10921555 8421376
- 8421440 5000192 5000230 2500096 2500115
- 16760576 16768896 10910720 10916179 8413184
- 8417344 4995328 4997926 2497792 2498835
- 16744448 16760704 10900224 10910803 8404992
- 8413248 4990464 4995366 2495232 2497811
- 16728064 16752512 10889472 10905683 8396800
- 8409152 4985600 4993062 2492928 2496531
- 16711680 16744576 10878976 10900307 8388608
- 8405056 4980736 4990502 2490368 2495251
- 16711744 16744607 10879017 10900328 8388640
- 8405072 4980755 4990512 2490378 2495256
- 16711808 16744639 10879059 10900348 8388672
- 8405088 4980774 4990521 2490387 2495261
- 16711871 16744671 10879100 10900369 8388704
- 8405104 4980793 4990531 2490397 2495265
- 16711935 16744703 10879142 10900390 8388736
- 8405120 4980812 4990540 2490406 2495270
- 12517631 14647551 8126630 9524134 6291584
- 7356544 3735628 4400716 1900582 2167590
- 8388863 12550399 5439654 8147878 4194432
- 6307968 2490444 3745356 1245222 1905446
- 4194559 10453247 2687142 6837158 2097280
- 5259392 1245260 3155532 655398 1577766
- 5526612 7763574 10000536 12303291 14540253
- 16777215
- )
- )
- )
-
- Back
-
- VxDeleteGroup - Deletes a group by name
-
-
- ;
- ; -- Function VxDeleteGroup
- ; Deletes a group by name
- ; Copyright:
- ; ?000 MENZI ENGINEERING GmbH, Switzerland
- ; Arguments [Typ]:
- ; Nme = Group name [STR]
- ; Return [Typ]:
- ; > Null
- ; Notes:
- ; 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...
- ;
- (defun VxDeleteGroup (Nme)
- (setq Gb:AcO (cond (Gb:AcO) ((vlax-get-acad-object)))
- Gb:AcD (cond (Gb:AcD) ((vla-get-activedocument Gb:AcO)))
- )
- (vl-catch-all-apply
- '(lambda ()
- (vla-delete
- (vla-item
- (vla-get-groups Gb:AcD)
- Nme
- )
- )
- )
- )
- (princ)
- )
-
- Back
-
- VxGetGroupNames - Returns a list of all Group name(s) of the object
-
-
- ;
- ; -- Function VxGetGroupNames
- ; Returns a list of all Group name(s) of the object.
- ; Copyright:
- ; ?001 MENZI ENGINEERING GmbH, Switzerland
- ; Arguments [Typ]:
- ; Obj = Object [VLA-OBJECT]
- ; Return [Typ]:
- ; > Group name(s) [LIST]
- ; Notes:
- ; 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...
- ;
- (defun VxGetGroupNames (Obj / Cur_ID NmeLst)
- (setq Gb:AcO (cond (Gb:AcO) ((vlax-get-acad-object)))
- Gb:AcD (cond (Gb:AcD) ((vla-get-activedocument Gb:AcO)))
- Cur_ID (vla-get-ObjectID Obj)
- )
- (vlax-for Grp (vla-get-Groups Gb:AcD)
- (vlax-for Ent Grp
- (if (equal (vla-get-ObjectID Ent) Cur_ID)
- (setq NmeLst (cons (vla-get-Name Grp) NmeLst))
- )
- (vlax-release-object Ent)
- )
- (vlax-release-object Grp)
- )
- (reverse NmeLst)
- )
-
- Back
-
- VxGetMassProps - Returns a list of all mass properties of the object
-
-
- ;
- ; -- Function VxGetMassProps
- ; Returns a list of all mass properties of the object.
- ; Copyright:
- ; ?001 MENZI ENGINEERING GmbH, Switzerland
- ; Arguments [Typ]:
- ; Obj = Object [VLA-OBJECT]
- ; Return [Typ]:
- ; > Mass properties '(Centroid RadiiOfGyration PrincipalDirections
- ; PrincipalMoments MomentOfInertia ProductOfInertia
- ; {Area Perimeter} {Volume}) [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 '(. . . . . . 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...
- ;
- (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 (list Obj) vlax-vbObject)
- )
- )
- 0
- )
- )
- (setq TmpObj Obj)
- )
- (setq ResLst (append
- (list
- (vlax-get TmpObj "Centroid")
- (vlax-get TmpObj "RadiiOfGyration")
- (vlax-get TmpObj "PrincipalDirections")
- (vlax-get TmpObj "PrincipalMoments")
- (vlax-get TmpObj "MomentOfInertia")
- )
- (if (= (vla-get-ObjectName TmpObj) "AcDbRegion")
- (list
- (vla-get-ProductOfInertia TmpObj)
- (vla-get-Area TmpObj)
- (vla-get-Perimeter TmpObj)
- )
- (list
- (vlax-get TmpObj "ProductOfInertia")
- (vla-get-Volume TmpObj)
- nil
- )
- )
- )
- )
- (if DelFlg (vla-delete TmpObj))
- ResLst
- )
-
- Back
-
- VxGetInters - Returns all intersection points between two objects
-
-
- ;
- ; -- Function VxGetInters
- ; Returns all intersection points between two objects.
- ; Copyright:
- ; ?000 MENZI ENGINEERING GmbH, Switzerland
- ; Arguments [Typ]:
- ; Fst = First object [VLA-OBJECT]
- ; Nxt = Second object [VLA-OBJECT]
- ; Mde = Intersection mode [INT]
- ; Constants:
- ; - acExtendNone Does not extend either object.
- ; - acExtendThisEntity Extends the Fst object.
- ; - acExtendOtherEntity Extends the Nxt object.
- ; - acExtendBoth Extends both objects.
- ; Return [Typ]:
- ; > list of points '((1.0 1.0 0.0)... [LIST]
- ; > Nil if no intersection found
- ; Notes:
- ; None
- ;
- (defun VxGetInters (Fst Nxt Mde / IntLst PntLst)
- (setq IntLst (vlax-invoke Fst "IntersectWith" Nxt Mde))
- (cond
- (IntLst
- (repeat (/ (length IntLst) 3)
- (setq PntLst (cons
- (list
- (car IntLst)
- (cadr IntLst)
- (caddr IntLst)
- )
- PntLst
- )
- IntLst (cdddr IntLst)
- )
- )
- (reverse PntLst)
- )
- (T nil)
- )
- )
-
- Back
-
- VxGetBlockInters - Returns all intersection points between a block and an obj...
-
-
- ;
- ; -- Function VxGetBlockInters
- ; Returns all intersection points between a Block and an object.
- ; Copyright:
- ; ?001-2002 MENZI ENGINEERING GmbH, Switzerland
- ; Arguments [Typ]:
- ; Blk = Block object [VLA-OBJECT]
- ; Obj = Object [VLA-OBJECT]
- ; Mde = Intersection mode [INT]
- ; Constants:
- ; - acExtendNone Does not extend either object.
- ; - acExtendThisEntity Extends the Fst object.
- ; - acExtendOtherEntity Extends the Nxt object.
- ; - acExtendBoth Extends both objects.
- ; Return [Typ]:
- ; > list of points '((1.0 1.0 0.0)... [LIST]
- ; > Nil if no intersection found
- ; Notes:
- ; None
- ;
- (defun VxGetBlockInters (Blk Obj Mde / ObjNme PntLst TmpVal)
- (foreach memb (vlax-invoke Blk "Explode")
- (setq ObjNme (vla-get-ObjectName memb))
- (cond
- ((or
- (not (vlax-method-applicable-p memb 'IntersectWith))
- (and
- (eq ObjNme "AcDbHatch")
- (eq (strcase (vla-get-PatternName memb)) "SOLID")
- )
- (eq ObjNme "AcDb3dSolid")
- )
- )
- ((eq ObjNme "AcDbBlockReference")
- (if (setq TmpVal (VxGetBlockInters memb Obj Mde))
- (setq PntLst (append PntLst TmpVal))
- )
- )
- (T
- (if (setq TmpVal (VxGetInters memb Obj Mde))
- (setq PntLst (append PntLst TmpVal))
- )
- )
- )
- (vla-Delete memb)
- )
- PntLst
- )
-
- Back
-
- VxGetObjLength - Returns the length of all kind of objects
-
-
- ;
- ; -- Function VxGetObjLength
- ; Returns the length of all kind of objects.
- ; Copyright:
- ; ?001 MENZI ENGINEERING GmbH, Switzerland
- ; Arguments [Typ]:
- ; Obj = Object [VLA-OBJECT]
- ; Return [Typ]:
- ; > Length of the object [REAL]
- ; Notes:
- ; - Proceedes *Polylines, Splines, Lines, Arcs, Circles and Ellipses
- ;
- (defun VxGetObjLength (Obj)
- (vlax-curve-getDistAtParam Obj (vlax-curve-getEndParam Obj))
- )
-
- Back
-
- VxSsetSelect - ActiveX counterpart to 'ssget'
-
-
- ;
- ; -- Function VxSsetSelect
- ; ActiveX counterpart to 'ssget'.
- ; Copyright:
- ; ?002 MENZI ENGINEERING GmbH, Switzerland
- ; Arguments [Typ]:
- ; Nme = Selection set name [STR]
- ; Mde = Select mode [INT] 1)
- ; Constants:
- ; - acSelectionSetWindow
- ; - acSelectionSetCrossing
- ; - acSelectionSetPrevious
- ; - acSelectionSetLast
- ; - acSelectionSetAll
- ; Pt1 = First window corner [LIST] 2)
- ; Pt2 = Next window corner [LIST] 2)
- ; Flt = Dotted pair list '((0 . "Name")...(8 . "Layer")) [LIST] 3)
- ; Return [Typ]:
- ; > New selection set [VLA-OBJECT]
- ; Notes:
- ; 1) If nil, SelectOnScreen is used
- ; 2) For select modes acSelectionSetWindow and acSelectionSetCrossing
- ; only, else nil
- ; 3) Set to nil if not used
- ;
- (defun VxSsetSelect (Nme Mde Pt1 Pt2 Flt / CurSet FltLst FstPnt NxtPnt)
- (setq CurSet (VxSsetMake Nme)
- FstPnt (cond (Pt1 (vlax-3d-point Pt1)) (T nil))
- NxtPnt (cond (Pt2 (vlax-3d-point Pt2)) (T nil))
- FltLst (cond (Flt (VxSsetFilter Flt)) (T nil))
- )
- (if Mde
- (if FltLst
- (vla-select CurSet Mde FstPnt NxtPnt (car FltLst) (cadr FltLst))
- (vla-select CurSet Mde FstPnt NxtPnt)
- )
- (if FltLst
- (vla-SelectOnScreen CurSet (car FltLst) (cadr FltLst))
- (vla-SelectOnScreen CurSet)
- )
- )
- CurSet
- )
-
- Back
-
- VxSsetMake - Creates a new selection set or clears an existing one
-
-
- ;
- ; -- Function VxSsetMake
- ; Creates a new selection set or clears an existing one.
- ; Copyright:
- ; ?002 MENZI ENGINEERING GmbH, Switzerland
- ; Arguments [Typ]:
- ; Nme = Selection set name [STR]
- ; Return [Typ]:
- ; > New selection set [VLA-OBJECT]
- ; Notes:
- ; 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...
- ;
- (defun VxSsetMake (Nme / SetCol)
- (setq Gb:AcO (cond (Gb:AcO) ((vlax-get-acad-object)))
- Gb:AcD (cond (Gb:AcD) ((vla-get-activedocument Gb:AcO)))
- SetCol (vla-get-SelectionSets Gb:AcD)
- )
- (if (vl-catch-all-error-p
- (vl-catch-all-apply 'vla-add (list SetCol Nme))
- )
- (vla-clear (vla-Item SetCol Nme))
- )
- (vla-Item SetCol Nme)
- )
-
- Back
-
- VxSsetFilter - Creates a filter for the SelectXxx methodes
-
-
- ;
- ; -- Function VxSsetFilter
- ; Creates a filter for the SelectXxx methodes.
- ; Copyright:
- ; ?002 MENZI ENGINEERING GmbH, Switzerland
- ; Arguments [Typ]:
- ; Flt = Dotted pair list '((0 . "Name")...(8 . "Layer")) [LIST]
- ; Return [Typ]:
- ; > List of two arrays '(TypArr DatArr) [LIST]
- ; Notes:
- ; None
- ;
- (defun VxSsetFilter (Flt)
- (mapcar
- '(lambda (Typ Dat) (VxListToArray Typ Dat))
- (list vlax-vbInteger vlax-vbVariant)
- (list (mapcar 'car Flt) (mapcar 'cdr Flt))
- )
- )
-
- Back
-
- VxListToArray - Converts a list into an array
-
-
- ;
- ; -- Function VxListToArray
- ; Converts a list into an array.
- ; Copyright:
- ; ?000 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
- )
- )
- )
-
- Back
-
- VxArrayToList - Converts an array into a list
-
-
- ;
- ; -- Function VxArrayToList
- ; Converts an array into a list.
- ; Copyright:
- ; ?000 MENZI ENGINEERING GmbH, Switzerland
- ; Arguments [Typ]:
- ; Arr = Array [VARIANT]
- ; Return [Typ]:
- ; > Standard List [LIST]
- ; > nil if array is empty
- ; Notes:
- ; - Can't be used for multidimensional arrays.
- ;
- (defun VxArrayToList (Arr / TmpVal)
- (setq TmpVal (vlax-variant-value Arr))
- (if (safearray-value TmpVal)
- (vlax-safearray->list TmpVal)
- '()
- )
- )
-
- Back
-
- VxStringSubst - Substitutes one string for another, within a string
-
-
- ;
- ; -- Function VxStringSubst
- ; Substitutes one string for another, within a string.
- ; Copyright:
- ; ?001 MENZI ENGINEERING GmbH, Switzerland
- ; Arguments [Typ]:
- ; Fnd = Pattern [STR]
- ; Rep = Replace [STR]
- ; Stg = String to search [STR]
- ; Return [Typ]:
- ; > Modified string [STR]
- ; Notes:
- ; None
- ;
- (defun VxStringSubst (Fnd Rep Stg / TmpStr)
- (setq TmpStr Stg)
- (while (vl-string-search Fnd TmpStr)
- (setq TmpStr (vl-string-subst Rep Fnd TmpStr))
- )
- TmpStr
- )
-
- Back
-
- VxGetDriveInfos - Returns informations from the selected drive
-
-
- ;
- ; -- Function VxGetDriveInfos
- ; Returns informations from the selected drive.
- ; Copyright:
- ; ?001 MENZI ENGINEERING GmbH, Switzerland
- ; Arguments [Typ]:
- ; Drv = Drive character, eg. "C" or "C:" [STR]
- ; Return [Typ]:
- ; > Drive infos '(TotalSize FreeSpace DriveType FileSystem SerialNumber
- ; ShareName VolumeName) [LIST]
- ; Explanations:
- ; - TotalSize (kB) [REAL]
- ; Returns the total space of a drive or network share.
- ; - FreeSpace (kB) [REAL]
- ; Returns the amount of space available to a user on the specified drive
- ; or network share.
- ; - DriveType [INT]
- ; 0 = "Unknown"
- ; 1 = "Removable"
- ; 2 = "Fixed"
- ; 3 = "Network"
- ; 4 = "CD-ROM"
- ; 5 = "RAM Disk"
- ; - FileSystem [STR]
- ; Returns the type of file system in use for the specified drive, eg.
- ; "FAT", "NTFS", "CDFS".
- ; - SerialNumber [INT]
- ; Returns the serial number used to uniquely identify a disk volume.
- ; - ShareName [STR]
- ; Returns the network share name (UNC) for the specified drive. If it's
- ; not a network drive, ShareName returns a zero-length string ("").
- ; - VolumeName [STR]
- ; Returns the volume name of the specified drive.
- ; > 0 The drive doesn't exist.
- ; > -1 The drive is not ready. For removable-media drives and CD-ROM drives,
- ; VxGetDriveInfos returns -1 when the appropriate media is not inserted
- ; or not ready for access.
- ; Notes:
- ; - Requires ScrRun.dll.
- ;
- (defun VxGetDriveInfos (Drv / DrvObj FilSys RetVal)
- (setq FilSys (vlax-create-object "Scripting.FileSystemObject")
- RetVal (cond
- ((= (vlax-invoke FilSys "DriveExists" Drv) 0) 0)
- ((setq DrvObj (vlax-invoke FilSys "GetDrive" Drv))
- (cond
- ((= (vlax-get DrvObj "IsReady") 0) -1)
- ((list
- (/ (vlax-get DrvObj "TotalSize") 1000.0)
- (/ (vlax-get DrvObj "FreeSpace") 1000.0)
- (vlax-get DrvObj "DriveType")
- (vlax-get DrvObj "FileSystem")
- (vlax-get DrvObj "SerialNumber")
- (vlax-get DrvObj "ShareName")
- (vlax-get DrvObj "VolumeName")
- )
- )
- )
- )
- )
- )
- (if DrvObj (vlax-release-object DrvObj))
- (vlax-release-object FilSys)
- RetVal
- )
-
- Back
-
- VxGetFileInfos - Returns informations from the selected file
-
-
- ;
- ; -- VxGetFileInfos
- ; Returns informations from the selected file.
- ; Copyright:
- ; ?002 MENZI ENGINEERING GmbH, Switzerland
- ; Arguments [Typ]:
- ; Fil = Filename "C:\\Temp\\MyTemp\\Scrap.dwg" [STR]
- ; Return [Typ]:
- ; > File infos '(DateCreated DateLastModified DateLastAccessed
- ; Type Size Attributes) [LIST]
- ; Explanations:
- ; - DateCreated [REAL]
- ; Returns serial date/time.
- ; - DateLastModified [REAL]
- ; Returns serial date/time.
- ; - DateLastAccessed [REAL]
- ; Returns serial date/time.
- ; - Type [STR]
- ; Returns the registered file tape, eg. "AutoCAD Drawing".
- ; - Size (kB) [REAL]
- ; Returns the size of the file in kB.
- ; - Attributes [INT]
- ; 0 = Normal file, no attributes are set.
- ; 1 = Read-only file.
- ; 2 = Hidden file.
- ; 4 = System file.
- ; 8 = Disk drive volume label. (not available in VxGetFileInfos)
- ; 16 = Folder or directory. (not available in VxGetFileInfos)
- ; 32 = File has changed since last backup.
- ; 64 = Link or shortcut.
- ; 128 = Compressed file.
- ; > nil If file doesn't exist
- ; Notes:
- ; - Requires ScrRun.dll.
- ;
- (defun VxGetFileInfos (Fil / FilObj FilSys RetVal)
- (setq FilSys (vlax-create-object "Scripting.FileSystemObject")
- RetVal (cond
- ((= (vlax-invoke FilSys "FileExists" Fil) 0) nil)
- ((setq FilObj (vlax-invoke FilSys "GetFile" Fil))
- (list
- (vlax-get FilObj "DateCreated")
- (vlax-get FilObj "DateLastModified")
- (vlax-get FilObj "DateLastAccessed")
- (vlax-get FilObj "Type")
- (/ (vlax-get FilObj "Size") 1000.0)
- (vlax-get FilObj "Attributes")
- )
- )
- (T nil)
- )
- )
- (if FilObj (vlax-release-object FilObj))
- (vlax-release-object FilSys)
- RetVal
- )
-
- Back
-
- VxCopyFiles - Copies the specified file(s)
-
-
- ;
- ; -- VxCopyFiles
- ; Copies the specified file(s).
- ; Copyright:
- ; ?002 MENZI ENGINEERING GmbH, Switzerland
- ; Arguments [Typ]:
- ; Src = Source file(s) to copy "C:\\Temp\\AllScrap.*" [STR]
- ; Tar = Target directory/file "C:\\Scrap" [STR]
- ; Return [Typ]:
- ; > T VxCopyFiles succeed
- ; nil Error on copy file(s)
- ; Notes:
- ; - Requires ScrRun.dll.
- ;
- (defun VxCopyFiles (Src Tar / ErrObj FilSys RetVal)
- (setq FilSys (vlax-create-object "Scripting.FileSystemObject")
- ErrObj (vl-catch-all-apply
- 'vlax-invoke-method
- (list FilSys 'CopyFile Src Tar :vlax-true)
- )
- RetVal (not (vl-catch-all-error-p ErrObj))
- )
- (vlax-release-object FilSys)
- RetVal
- )
-
- Back
-
- VxDeleteFiles - Deletes the specified file(s)
-
-
- ;
- ; -- VxDeleteFiles
- ; Deletes the specified file(s).
- ; Copyright:
- ; ?002 MENZI ENGINEERING GmbH, Switzerland
- ; Arguments [Typ]:
- ; Fil = File name(s) to delete "C:\\Temp\\AllScrap.*" [STR]
- ; Return [Typ]:
- ; > T VxDeleteFiles succeed
- ; nil Error on delete file(s)
- ; Notes:
- ; - Requires ScrRun.dll.
- ;
- (defun VxDeleteFiles (Fil / ErrObj FilSys RetVal)
- (setq FilSys (vlax-create-object "Scripting.FileSystemObject")
- ErrObj (vl-catch-all-apply
- 'vlax-invoke-method
- (list FilSys 'DeleteFile Fil :vlax-true)
- )
- RetVal (not (vl-catch-all-error-p ErrObj))
- )
- (vlax-release-object FilSys)
- RetVal
- )
-
- Back
-
- VxCreateDirectory - Creates the specified directory(ies)
-
-
- ;
- ; -- VxMakeDirectory
- ; Creates the specified directory(ies).
- ; Copyright:
- ; ?001 MENZI ENGINEERING GmbH, Switzerland
- ; Arguments [Typ]:
- ; Dir = Folder to create, eg. "C:\\Temp\\MyTemp\\AllScrap" [STR]
- ; Return [Typ]:
- ; > T VxMakeDirectory succeed
- ; nil Error on creating directory(ies)
- ; Notes:
- ; - Requires ScrRun.dll.
- ;
- (defun VxMakeDirectory (Dir / CurDir DrvObj FilSys RetVal TmpLst TmpVal)
- (setq FilSys (vlax-create-object "Scripting.FileSystemObject")
- CurDir (vl-string-right-trim "\" (vl-string-right-trim "/" Dir))
- )
- (while (/= (setq TmpVal (vl-filename-directory CurDir)) CurDir)
- (setq TmpLst (cons TmpVal TmpLst)
- CurDir TmpVal
- )
- )
- (setq RetVal (cond
- ((= (vlax-invoke FilSys "DriveExists" TmpVal) 0) nil)
- ((setq DrvObj (vlax-invoke FilSys "GetDrive" TmpVal))
- (cond
- ((= (vlax-get DrvObj "IsReady") 0) nil)
- (T
- (foreach memb TmpLst
- (cond
- ((= (vlax-invoke FilSys "FolderExists" memb) -1))
- ((vlax-invoke FilSys "CreateFolder" memb))
- )
- )
- (cond
- ((= (vlax-invoke FilSys "FolderExists" Dir) -1))
- ((vlax-invoke FilSys "CreateFolder" Dir) T)
- (T nil)
- )
- )
- )
- )
- )
- )
- (if DrvObj (vlax-release-object DrvObj))
- (vlax-release-object FilSys)
- RetVal
- )
-
- Back
-
- VxDelDirectory - Deletes the specified directory
-
-
- ;
- ; -- VxDelDirectory
- ; Deletes the specified directory.
- ; Copyright:
- ; ?002 MENZI ENGINEERING GmbH, Switzerland
- ; Arguments [Typ]:
- ; Dir = Folder to delete "C:\\Temp\\MyTemp\\AllScrap" [STR]
- ; Return [Typ]:
- ; > T VxDelDirectory succeed
- ; nil Error on deleting directory
- ; Notes:
- ; - Requires ScrRun.dll.
- ;
- (defun VxDelDirectory (Dir / FilSys RetVal)
- (setq FilSys (vlax-create-object "Scripting.FileSystemObject")
- RetVal (cond
- ((= (vlax-invoke FilSys "FolderExists" Dir) 0) nil)
- (T (vlax-invoke FilSys "DeleteFolder" Dir :vlax-true) T)
- )
- )
- (vlax-release-object FilSys)
- RetVal
- )
-
- Back
-
- VxReadTextFile - Reads a textfile and returns a line list (fast)
-
-
- ;
- ; -- VxReadTextFile
- ; Reads a textfile and returns a line list (fast).
- ; Copyright:
- ; ?001 MENZI ENGINEERING GmbH, Switzerland
- ; Arguments [Typ]:
- ; Fil = (Path)Filename [STR]
- ; Return [Typ]:
- ; > List of lines [LIST]
- ; > nil if file not found
- ; Notes:
- ; - Requires ScrRun.dll.
- ;
- (defun VxReadTextFile (Fil / FilObj FilPth FilSys OpnFil RetVal)
- (if (setq FilPth (findfile Fil))
- (progn
- (setq FilSys (vlax-create-object "Scripting.FileSystemObject")
- FilObj (vlax-invoke FilSys "GetFile FilPth")
- OpnFil (vlax-invoke FilObj "OpenAsTextStream" 1 0)
- )
- (while (= (vlax-get OpnFil "AtEndOfStream") 0)
- (setq RetVal (cons (vlax-invoke OpnFil "ReadLine") RetVal))
- )
- (vlax-invoke OpnFil "Close")
- (vlax-release-object OpnFil)
- (vlax-release-object FilObj)
- (vlax-release-object FilSys)
- (reverse RetVal)
- )
- nil
- )
- )
-
- Back
-
- VxCreateShortCut - Creates a shortcut to AutoCAD with the appropriate...
-
-
- ;
- ; -- Function VxCreateShortCut
- ; Creates a shortcut to AutoCAD with the appropriate parameters on the desktop.
- ; Copyright:
- ; ?002 MENZI ENGINEERING GmbH, Switzerland
- ; Arguments [Typ]:
- ; Scn = Shortcut name, "MyShortCut" [STR]
- ; Pro = Profile name, "MyProfile" [STR]
- ; Icn = (Path)Filename of the icon, "c:\\MyPath\\MyIcon.ico" [STR] 1)
- ; Return [Typ]:
- ; > Shortcutpath if suceed [STR]
- ; > False on error
- ; Notes:
- ; 1) If nil, AutoCAD's first internal icon is used
- ; - Requires ScrRun.dll.
- ;
- (defun VxCreateShortCut (Scn Pro Icn / DskPth IcnPar ExeFil RetVal ShoCut
- SpcFld WscObj)
- (setq ExeFil (findfile "acad.exe")
- IcnPar (cond (Icn) ((strcat ExeFil ", 0")))
- WscObj (vlax-create-object "WScript.Shell")
- RetVal (cond
- ((setq SpcFld (vlax-get WscObj 'SpecialFolders))
- (setq DskPth (strcat
- (vla-Item SpcFld "Desktop")
- "\" Scn ".lnk"
- )
- ShoCut (vlax-invoke WscObj "CreateShortcut" DskPth)
- )
- (vlax-put-property ShoCut 'TargetPath ExeFil)
- (vlax-put-property ShoCut 'Arguments (strcat "/p " Pro))
- (vlax-put-property ShoCut 'IconLocation IcnPar)
- (vla-save ShoCut)
- (findfile DskPth)
- )
- (T Nil)
- )
- )
- (vlax-release-object WscObj)
- RetVal
- )
-
- Back
-
- ACAD2000.lsp - Drawing Reactor sample
-
-
- ;
- ; -- ACAD2000.lsp
- ; Sets a DocManager Reactor to release the Gb:AcO and Gb:AcD objects at the
- ; end of a AutoCAD session.
- ; Copyright:
- ; ?000 MENZI ENGINEERING GmbH, Switzerland
- ; Notes:
- ; None
- ;
- (setq vlax-vbDecimal 14) ;Set missing Datatype
- (if s::startup
- (defun-q-list-set
- 's::startup
- (append
- (defun-q-list-ref 's::startup)
- (cdr (defun-q-list-ref 'InitReactor))
- )
- )
- (defun-q s::startup () (InitReactor) (princ))
- )
- (defun-q InitReactor ()
- (prompt "\n>Initialize Document Reactor...")
- (vl-load-com)
- (if (not Gb:DmR)
- (setq Gb:DmR (vlr-DocManager-Reactor
- nil
- '((:vlr-documentToBeDestroyed . CloseHandling))
- )
- )
- )
- (princ)
- )
- (defun CloseHandling (Rea Arg)
- (if Gb:AcO (vlax-release-object Gb:AcO))
- (if Gb:AcD (vlax-release-object Gb:AcD))
- (vlr-remove-all :vlr-DocManager-Reactor)
- (setq Gb:AcO nil
- Gb:AcD nil
- Gb:DmR nil
- )
- (princ)
- )
- (princ)
- ;
- ; -- End ACAD2000.lsp
- [/FONT]
|
|