|
|

楼主 |
发表于 2009-10-22 12:55:03
|
显示全部楼层
来自: 中国湖北十堰
本来想晚上回来在试试的4 j- S1 P) u" R; d) n4 s- i
但是现在不试睡不着
& U1 ?' C* T- d7 g8 n( [ u嘿嘿5 G0 N6 h$ M0 I7 k* W
6 o# L1 U7 }) ]) S' m' W0 m' r
试了试
5 |/ _& e) u$ Z0 ~4 c谢谢版主 打开了那个文件. p! i2 T7 C# r9 p2 D
下面是代码& v8 Z9 F1 k9 F' W* i, g
'Declare Function GS_MHDog Lib "win32dll.dll" (DogData As MH_DLL_PARA) As Long
0 R. B8 V& y9 @4 U& g. ~'Declare Function InstDrv Lib "RCMicroDogSetup.dll" Alias "InstDriver" (ByVal a As Integer) As Integer! T; o- `: X6 g u. L; I
'Declare Function UninstDrv Lib "RCMicroDogSetup.dll" Alias "UninstallDriver" (ByVal a As Integer) As Integer& M* R! V, p' O, J1 [) P
'Declare Function GetDogDriverInfo Lib "RCMicroDogSetup.dll" () As Long0 N8 E$ q, a, X+ O
'Declare Sub DriverDialog Lib "RCMicroDogSetup.dll" ()* M; o7 k5 }8 S4 R H9 K
'Declare Function NotifyPullOutAndPlugInUsbDog Lib "RCMicroDogSetup.dll" (ByVal a As Integer) As Integer
: p& u, T* K% K2 f# G
# ?6 U A( w% N4 _: C0 K* S'Declare Function yy Lib "jmcar.dll" () As Long
' t* A/ ^* |6 M' O. m/ a'Public xxx As New CAMZDSHXJ
/ U Q9 m7 W% C4 N. O2 JConst SYNCHRONIZE = &H1000007 S3 H- f6 y7 ^" z9 j. m# ?/ a9 M! m
Const INFINITE = &HFFFFFFFF
' V, F2 O) k R/ QPrivate Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long* L9 A, t7 P3 g* Z# v! e
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
6 F& O. p$ O5 Y9 f7 S0 @9 ZPrivate Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long' ^' O4 [ l& O0 ~ r
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long; H8 ? Z, `' Z6 G2 s8 _8 \
$ e4 J4 U; j1 Z4 F* sPublic Function getmac() As String
' K3 N' c! B2 ^ _# x7 R Dim retval0 G# {/ M! F3 `' q: L* x, r
Dim pId As Long, pHnd As Long ' 分别声明 Process Id 及 Process Handle 变数. b$ a1 H( y% V) z+ y* ~
Dim MYSTR, lstr As String
& G7 p, P/ T' E If Dir("D:\cnc\hxj1.txt") = "" Then
" E" c9 s+ F4 h+ V6 l8 T5 ~ Else9 R; ]. u* x, t% P* ]
Kill "d:\cnc\hxj1.txt "
: Z* ~! m. S# g End If
, `0 A% t% i! V: ^7 c pId = Shell("cmd /C ipconfig /all > D:\CNC\hxj1.txt ", 0) ' Shell 传回 Process Id4 e1 T/ N7 } _' i8 n
pHnd = OpenProcess(SYNCHRONIZE, 0, pId) ' 取得 Process Handle# p$ O! h; y/ ~$ m$ W; ^0 f
If pHnd <> 0 Then5 Z" P! {5 y! J- A; \
Call WaitForSingleObject(pHnd, INFINITE) ' 无限等待,直到程序结束$ d# l. R1 ?# N4 ^: E' f/ j1 P
Call CloseHandle(pHnd)# Q' |0 \; ]1 D/ \- o+ `, X; I
End If
! B/ W' I! Q& t- W$ E+ t: o Close
9 s& b9 s6 J3 \ Open "d:\cnc\hxj1.txt " For Input As #3
5 k. X! w2 m2 D/ { Do While Not EOF(3)
+ ^2 v9 u! N, G) [: g6 _% q+ j Line Input #3, lstr
) d3 [/ ~8 o; [ If InStr(lstr, "Physical Address") > 1 Then) m& o5 B8 D8 d1 `6 j
MYSTR = Split(lstr, ":", 2, 1)8 S" v$ G: h0 z( w$ F) b$ @% U$ {& i# n
getmac = MYSTR(1)
. H! I5 n ?7 O2 b1 M Exit Do! b; `& ]6 I# t/ _+ t
End If
! W: D' ~# [ j* [3 ? Loop% Z+ N9 ?8 S+ e% u! I) Y: H \
Close' ?+ K* y: |3 m/ n' G+ e
End Function* V$ D: ~* w; B) m4 u; u/ J* _6 Y$ }
Public Sub DelDoubleALL() '删除重复图素
* B4 P4 D8 F; z! _+ \ Dim i, j, k As Integer
% G7 W, Q: t; Y+ Y1 T; O$ S5 F Dim ssetObj As AcadSelectionSet
4 M* K: A" } Y Z2 A Dim dege1 As Double, dege2 As Double4 Q# b: I6 B6 h
Dim dege3 As Double, dege4 As Double0 k' p7 F" ?. c! Y0 D- ?* `
Dim pt1 As Variant, pt2 As Variant, Yuanr As Double, yuanr2 As Double3 T7 q. C) f2 B3 j
Dim pt10 As Variant, pt20 As Variant, Yuanr1 As Double
/ L: V* u7 P* f Dim ic As Integer
1 C5 v( \. P% X4 ~: u Dim str1 As String, str2 As String, id1 As String, id2 As String0 Z' r$ y i- u5 e8 @+ q; h+ d
Dim EntName() As String, line1() As Variant, line2() As Variant
% ]% @, ], o5 S; j# o( t Dim line3() As Double
' H; i8 C5 d/ D Dim arc1() As Variant, arc2() As Double, arc3() As Double, arc4() As Double
) g: a% H u* {6 y Dim cir1() As Variant, cir2() As Double, blk1() As Variant+ l r1 f. [) b" {. R3 a
Dim blk2() As String
" t* x) w% l) t. b! e ic = ThisDrawing.SelectionSets.Count '选择集的个数9 @( ]6 c, o- p) l3 T [
If ic > 0 Then
/ k) ?2 M8 f% ^ For i = ic - 1 To 0 Step -1* Z. L: c3 f/ H( z; v( x
Set ssetObj = ThisDrawing.SelectionSets(i)7 L1 t3 S& g: p7 Q! u! i+ t3 O
If ssetObj.Name = "SSSS" Then ssetObj.Delete '存在该选择集删除它
& l, K, J# a. p) {( {5 F Next! o2 _' i8 r" P
End If2 A' e: B3 Y Q; W
Set ssetObj = ThisDrawing.SelectionSets.Add("SSSS")
2 r. T8 w3 \* Y' N ' Add objects to a selection set by prompting user to select on the screen
; h6 e2 H7 @% I3 a' ssetObj.SelectOnScreen
' Y# B; e. W- J' ?. E ssetObj.Select acSelectionSetAll '把全部图形加入选择集
0 ]# A6 A, h/ C3 [9 @$ ?) }' sele1.Select acSelectionSetAll, , , ft, fd '层选择
' S7 c1 b6 S4 r! f On Error GoTo ccc14 q/ d! G6 O y
ic = ssetObj.Count - 1
, V' z1 y) p9 s& x9 Y If ic < 1 Then '选择集孔或图素小于2则退出
o- ~" ^ m% h Exit Sub. t. A9 v8 A; B# R" C" U* g6 E V
End If
7 ?6 _) E6 l( d1 Y& |; z/ W, u ReDim EntName(0 To ic)! B" x' c e7 }+ A& y5 G
ReDim line1(0 To ic): ReDim line2(0 To ic): ReDim line3(0 To ic)2 w; C) U. |' T, y
ReDim arc1(0 To ic): ReDim arc2(0 To ic): ReDim arc3(0 To ic)
" u' Q3 q4 v! p! E ReDim arc4(0 To ic)+ b9 V) y6 u* R- _! S% B# e
ReDim cir1(0 To ic): ReDim cir2(0 To ic)
6 ?1 `6 j7 V* j9 k( `8 I; H ReDim blk1(0 To ic): ReDim blk2(0 To ic)/ a2 \6 ^& e4 E+ @& l/ w# p
With ssetObj
* q l, S$ M) k) r+ }/ a0 L0 R$ I For i = 0 To ic+ ~) u9 j* {0 `: Q* w4 L/ _ n
EntName(i) = ssetObj.Item(i).ObjectName: {% _. G ^4 {( \" V7 r2 F
Select Case EntName(i)
+ F0 v3 G2 Q3 B; x% l Case "AcDbLine" y5 L* N, t; R' g) A$ M* E- s; |
line1(i) = .Item(i).StartPoint
. a4 ~! T( m$ R. |8 I% p line2(i) = .Item(i).EndPoint
+ z/ R. ]% ^5 ? line3(i) = .Item(i).Angle( \0 |1 f$ l# v% f) [1 }4 v" X
Case "AcDbCircle"
/ l" u9 w* Z- @; k8 O/ J4 p6 y cir1(i) = .Item(i).Center2 a: w- u1 d& Z# q! N& a
cir2(i) = Int(.Item(i).Radius * 1000) / 1000
: v9 ~- k# Q; s& W* p ^8 b* B Case "AcDbArc"
* d) u" t+ l/ A4 d/ B, w3 W- w arc1(i) = .Item(i).Center
& b( f, t* s( s4 H5 r arc2(i) = Int(.Item(i).StartAngle * 1000) / 1000 z5 x8 h! G1 B
arc3(i) = Int(.Item(i).EndAngle * 1000) / 1000
# _6 |! p% O2 v5 m# g arc4(i) = Int(.Item(i).Radius * 1000) / 1000
$ |4 a( P" n. n6 { Case "AcDbBlockReference"
: p; s: O% o: x blk1(i) = .Item(i).InsertionPoint( G- Z# q( ~; x( `
blk2(i) = .Item(i).Name) W( A R/ v/ ]3 U, m
End Select
) y6 H& K; g1 e% L' A
% q. z, z- T: y Next i! |, f0 u& g" m# r* ?( Y
3 F5 X2 A( m7 E
For i = 0 To ic - 14 x$ F1 X, d' g% D3 e9 ?& u+ p# Z
id1 = EntName(i) u" ?* p4 X" V$ t9 B; a) ]
For j = i + 1 To ic) n2 C. l( s$ E) n5 Y' [7 W5 i4 o
id2 = EntName(j)8 \5 |8 f8 ~- H0 f4 a. R( M, |' F
If id1 = id2 Then# f& T) L+ w; x* }3 q b
Select Case id1
7 j* u( O4 T: d' y% A3 q5 Y( I Case "AcDbLine" v% ?0 D. \$ w. g; L5 c/ O+ ^) a0 C
pt1 = line1(i)
: {/ R# a. D" Y pt2 = line2(i)2 w; E6 C" O6 q/ a
dege1 = line3(i)1 L9 M) R4 u5 D$ r1 ]
pt10 = line1(j)
9 W5 \) X( f, b; T m/ h pt20 = line2(j)& J* `1 T* @- G. l+ B7 v) B
dege2 = line3(j). I7 h' F/ O6 _; S
If Abs(pt1(0) - pt10(0)) < 0.01 And Abs(pt1(1) - pt10(1)) < 0.01 And _( F0 ?0 Y. h; K0 S
Abs(pt2(0) - pt20(0)) < 0.01 And Abs(pt2(1) - pt20(1)) < 0.01 Then S& l3 [ J; A* ]; e
.Item(i).Delete0 b1 D: c4 `3 `$ Q9 F
Exit For% u p/ d" |% o- p' v
End If
( J% p; r/ P% R5 z* h" X+ z; R If Int(Abs(dege1 - dege2) * 10000 + 0.5) / 10000 = 3.1416 Then
/ s6 y: Y, P1 ] If Abs(pt1(0) - pt20(0)) < 0.01 And Abs(pt1(1) - pt20(1)) < 0.01 And _* R$ v& ]- m9 P6 O1 d! I6 p
Abs(pt2(0) - pt10(0)) < 0.01 And Abs(pt2(1) - pt10(1)) < 0.01 Then- v/ y/ Y5 Y7 H2 c6 n
.Item(i).Delete1 }$ E) }! N. b
Exit For& N' `- J( ~& v
End If- `% G, m% Q+ X& k4 {
End If
, \+ g' x% G4 F8 d Case "AcDbCircle"* i' F( D! I( H% G
pt1 = cir1(i)/ `* G0 F# [8 b G7 J& _: d
Yuanr = cir2(i)6 H3 U6 ?4 a$ S5 h6 x! e
pt2 = cir1(j)
: q' v; G/ M) L; r6 K: b1 y yuanr2 = cir2(j)( E% h) [, S" P' Z$ R
If Sqr((pt1(0) - pt2(0)) ^ 2 + (pt1(1) - pt2(1)) ^ 2) < 0.01 And Yuanr = yuanr2 Then
( G% k$ v p3 |/ w .Item(i).Delete* W* i; U) ?9 [' r7 E
Exit For
% L, R6 c9 ~* S' U: ~$ C3 M, I Else
. G5 `/ s5 H% U4 m, z' e# N If Sqr((pt1(0) - pt2(0)) ^ 2 + (pt1(1) - pt2(1)) ^ 2) < 8 Then
& I- m1 q! D O5 B .Item(i).color = acGreen5 A/ `: I4 I8 W" n# Y, Q1 w9 N
End If
3 L8 H& C& O4 d! K& B- `7 o* { End If
! i$ V1 v& Y4 N+ | Case "AcDbArc"
' u: a2 z& P+ c' g% ^1 ^ pt1 = arc1(i)
) k9 |1 ~* y2 p: @. Z dege1 = arc2(i)
6 ~$ s5 W4 S9 Q# a dege2 = arc3(i)
, `4 g; h) J( ^: ~( {2 {; A, @ Yuanr = arc4(i)6 @- s: z2 a- {8 V
pt2 = arc1(j)
' n9 l7 Y; Y M dege3 = arc2(j), @/ R+ Y" |) C
dege4 = arc3(j)& \+ H& K, g5 O5 W5 \
yuanr2 = arc4(j)$ w6 q* q- Y: N
If Abs(pt1(0) - pt2(0)) < 0.01 And Abs(pt1(1) - pt2(1)) < 0.01 And Yuanr = yuanr2 _
, b. I, p! k8 q5 ?: X' x) W( i And dege1 = dege3 And dege2 = dege4 Then
, P: v5 r' K: y$ \5 r .Item(i).Delete
0 W% P: ?) D7 b, r5 k) A Exit For9 `% C( b* u. S1 @
End If: t( K' a; f* }5 O
Case "AcDbBlockReference"
- y- G" L5 s* @$ I( C; b pt1 = blk1(i)$ x( `/ f- A4 Q) V X. B- N! Q. K
str1 = blk2(i)
" s* [% y* A2 A6 @; ~6 q pt2 = blk1(j)
2 K$ U3 o3 _% R9 } str2 = blk2(j)
- j" A2 P/ } C If Abs(pt1(0) - pt2(0)) < 0.01 And Abs(pt1(1) - pt2(1)) < 0.01 And _. T: R H8 Q2 L9 M7 G
Trim(str1) = Trim(str2) Then
" l- d1 n) D' }! K* r# X .Item(i).Delete) t4 X' N% w" t0 ~7 k' f; ^
Exit For# I2 I' y( C8 E) t. Y2 n
End If
- u# x2 C. a" A1 Q End Select
2 Z5 ?0 q% H6 \! _. B End If: b' x U* L1 v, T$ V8 t; w' i' B6 n
Next j
& Q$ a! U3 W2 \- h7 c$ a: R6 `2 s Next i& N% d# ]$ t g0 s2 y5 ?
End With0 Q; A; }; J: l; | B" d1 Q
' MsgBox "删除重复完成!"1 s" D7 }% o/ S/ [0 I$ d
GoTo ccc2
& }1 t/ l& A% W6 Sccc1: MsgBox "有错!!!"9 o, ^7 F7 ?1 w+ O& E# X: o
ccc2: 'ssetObj.Delete: y8 X& x, v! ]
7 p7 q F1 f. W! Q( y+ f4 \
End Sub
4 s9 B7 H; b7 [5 J+ s; `% g0 D9 I ]; k- m# a* E/ }8 ~4 E& v
Public Function Clamp100(a1 As Double) As Double '判断块存在不存在,存在=100,不存在=0
$ V+ \9 J# J2 \6 ~ Dim p1(0 To 2) As Double '交叉选择的左下角点
2 Q# A) C8 L" x4 ]5 F0 s Dim p2(0 To 2) As Double '交叉选择的右上角点
+ R! }, ~) D$ D2 ^. `- {# k: I Dim ssetObj As AcadSelectionSet, e4 F4 t2 Q3 L) V% c
Dim ic As Integer, j As Integer# h b! F7 B. p( V) a# K4 n- g
ThisDrawing.SelectionSets("SSSS").Delete j6 }7 n0 J& ?1 g, Y' b! k
Set ssetObj = ThisDrawing.SelectionSets.Add("SSSS")0 O) D O4 G2 N
p1(0) = a1 - 15: p1(1) = -25: p1(2) = 08 Y; _. c+ u- c$ _ L
p2(0) = a1 + 15: p2(1) = -5: p2(2) = 0" [5 O* O5 ^0 T1 N; v0 k
ssetObj.Select acSelectionSetWindow, p1, p2
M/ R3 D! R2 c' h For j = 0 To ssetObj.Count - 1' I9 L$ q% R2 J
ssetObj.Item(j).color = acGreen9 M0 i; K8 x9 N" G# m* \) @
ssetObj.Item(j).Update/ n$ z5 {( G2 E8 |; S. z" e# ~1 V
Next j$ p% ]& O/ J; V3 X& [" ~% s
Clamp100 = ssetObj.Count
3 _5 B5 _. ~) T1 j/ L0 FEnd Function
; t% m5 T. C' E w5 y: R3 R/ N, {' a+ P4 ~
9 s+ ^- m5 ]* J* y5 ^/ [# D6 N0 \, G$ T
- E! P+ y- e5 o, l/ @ ^* E; s, n看不太懂 不过 我在这里多学学 应该没问题的 嘿嘿 |
|