|
|

楼主 |
发表于 2009-10-22 12:55:03
|
显示全部楼层
来自: 中国湖北十堰
本来想晚上回来在试试的+ `1 M; F8 \5 J7 j
但是现在不试睡不着 * D* e. T8 _4 w
嘿嘿. g$ D% j- S$ R- o
* M3 ^: d8 Z. `4 B: l& t
试了试
/ O6 C/ C! m1 V. t- ~. y谢谢版主 打开了那个文件
- [0 b/ I; O5 X0 Q O% B下面是代码
( ]! C6 h+ f6 E. C0 s'Declare Function GS_MHDog Lib "win32dll.dll" (DogData As MH_DLL_PARA) As Long
8 I9 p8 q! W/ F) ~'Declare Function InstDrv Lib "RCMicroDogSetup.dll" Alias "InstDriver" (ByVal a As Integer) As Integer
: Z5 ~; y( M7 ^# E'Declare Function UninstDrv Lib "RCMicroDogSetup.dll" Alias "UninstallDriver" (ByVal a As Integer) As Integer& _- |( [0 D" P& Q
'Declare Function GetDogDriverInfo Lib "RCMicroDogSetup.dll" () As Long. b4 @$ z7 Z& A3 N* ]' q
'Declare Sub DriverDialog Lib "RCMicroDogSetup.dll" ()1 Y8 q3 @" ^& W7 j) M4 W
'Declare Function NotifyPullOutAndPlugInUsbDog Lib "RCMicroDogSetup.dll" (ByVal a As Integer) As Integer+ R" y' E, O6 d
) c, R, w8 z8 z3 E
'Declare Function yy Lib "jmcar.dll" () As Long
6 ^2 \5 B# n2 h'Public xxx As New CAMZDSHXJ9 t* V" Y6 q. S% T1 f
Const SYNCHRONIZE = &H1000007 K" A) s" E v4 i- _" F
Const INFINITE = &HFFFFFFFF
, M& [, O6 a6 z/ p1 M: D; s3 O: qPrivate Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long# r! }. o# v3 J. H! K
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long6 j6 J% u/ ]' p
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long" P0 x" e$ P _% {
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
5 t: q& G4 {% S0 Z. r3 u+ Q- u8 M( b* ^2 q1 p
Public Function getmac() As String* k9 {2 G( M2 G! E8 a1 }7 h$ I
Dim retval0 T6 {/ T# J" f) @" D
Dim pId As Long, pHnd As Long ' 分别声明 Process Id 及 Process Handle 变数% r, Y: D. O! `' G" K
Dim MYSTR, lstr As String9 \& s: ~8 D+ C/ l0 [: X
If Dir("D:\cnc\hxj1.txt") = "" Then
2 K, T( Q5 ~$ O7 z Else
6 ~( s3 d1 U$ p j. ]4 q5 ?9 o Kill "d:\cnc\hxj1.txt "
}7 `3 @( O t# o: F- |4 x9 F End If
2 |6 q' l5 ?, q6 }9 G' ~% A pId = Shell("cmd /C ipconfig /all > D:\CNC\hxj1.txt ", 0) ' Shell 传回 Process Id) S4 T* S7 ~0 G' L3 E& X
pHnd = OpenProcess(SYNCHRONIZE, 0, pId) ' 取得 Process Handle Q6 ]& b" w' q% n% [, H, }
If pHnd <> 0 Then+ Q3 W& M# [4 |& C4 h# z
Call WaitForSingleObject(pHnd, INFINITE) ' 无限等待,直到程序结束/ e9 N: ^7 T- z, h+ ^9 O! |$ b
Call CloseHandle(pHnd)
_; d p3 y% l4 e End If7 B. P1 x8 R) x- Y8 R; T
Close$ y; f8 M/ J; ^% Y/ i
Open "d:\cnc\hxj1.txt " For Input As #3* @9 k4 w$ o2 i3 E3 U
Do While Not EOF(3)- K% k6 J2 W: G# @( r$ o
Line Input #3, lstr; R9 s4 C, i" J+ J; {" \
If InStr(lstr, "Physical Address") > 1 Then7 P; Y1 ~* t* ~- P, N$ K
MYSTR = Split(lstr, ":", 2, 1)/ k) l } F( z. l; w
getmac = MYSTR(1)
6 l4 R& L: `! H; e( m6 ^ Exit Do0 T! C1 w9 H4 e+ x
End If, d- h& V1 l4 x, c. N* @" ~
Loop
$ t+ o; ?' f1 ~! X3 _ Close7 Y" Y! ~) u+ T O
End Function
- U9 g' o- o2 L Public Sub DelDoubleALL() '删除重复图素1 p- \3 W6 Y7 q+ c
Dim i, j, k As Integer# R, F# M! t9 f) t' R
Dim ssetObj As AcadSelectionSet2 \( X& z t$ u( S) U; H
Dim dege1 As Double, dege2 As Double2 A, ]$ @. h |$ c9 m
Dim dege3 As Double, dege4 As Double
- D$ k" U M) r Dim pt1 As Variant, pt2 As Variant, Yuanr As Double, yuanr2 As Double; S% q1 |+ Z6 l7 E) `# X" b: J8 H
Dim pt10 As Variant, pt20 As Variant, Yuanr1 As Double3 u( Y; \6 b2 W1 \4 j; g8 U6 T& @
Dim ic As Integer
$ C; E9 Z4 z) N( D% S; N/ ]/ |% O Dim str1 As String, str2 As String, id1 As String, id2 As String& A5 c& N" m" o- {3 |. K7 A
Dim EntName() As String, line1() As Variant, line2() As Variant; T. Q/ O P; h y
Dim line3() As Double7 |3 ]/ I2 ~$ ^( ]; _
Dim arc1() As Variant, arc2() As Double, arc3() As Double, arc4() As Double- G5 a8 t' l' J1 }
Dim cir1() As Variant, cir2() As Double, blk1() As Variant9 N0 G4 \, T% K! J
Dim blk2() As String5 j) T( }1 K5 R' W4 |
ic = ThisDrawing.SelectionSets.Count '选择集的个数. p+ b& O P0 P, J
If ic > 0 Then
9 g/ S% r- a8 @ G) q; p: {) G' f For i = ic - 1 To 0 Step -12 z7 C5 N5 E+ e s; A% R* L
Set ssetObj = ThisDrawing.SelectionSets(i)
5 M4 t/ L5 s, x' z If ssetObj.Name = "SSSS" Then ssetObj.Delete '存在该选择集删除它
' k, D$ ^. c: I- u. t' [9 w Next
* o k8 Y7 l5 i0 zEnd If
0 j* k/ N+ l% \* C2 }1 w! N Set ssetObj = ThisDrawing.SelectionSets.Add("SSSS")
0 B) Q( @( J6 H) ]3 w5 r: z. M4 \ ' Add objects to a selection set by prompting user to select on the screen
5 `/ K& k$ j9 j4 _' \; ^) l' ssetObj.SelectOnScreen
7 A0 z( a" D8 r ssetObj.Select acSelectionSetAll '把全部图形加入选择集
6 W0 ~: \: M$ f8 |5 @' sele1.Select acSelectionSetAll, , , ft, fd '层选择
/ w: d% h" J* b V On Error GoTo ccc1; E+ `2 O7 G0 H [" |; C* b1 j; L
ic = ssetObj.Count - 1
) M' n8 q$ {, ^. h! k- A If ic < 1 Then '选择集孔或图素小于2则退出+ o) r4 K: `2 ^( w/ ^
Exit Sub
; V' q0 c0 z+ Z/ U6 D. E End If1 Z( [% ~1 ], P- ?# V. l; h
ReDim EntName(0 To ic)
u1 v4 M* h L G2 W: Z ReDim line1(0 To ic): ReDim line2(0 To ic): ReDim line3(0 To ic)
- g" ~* k) p7 b! v3 Q0 e ReDim arc1(0 To ic): ReDim arc2(0 To ic): ReDim arc3(0 To ic)" S2 o6 B( i3 b7 k& Q
ReDim arc4(0 To ic)$ m4 n3 E7 R9 E( c: h! t
ReDim cir1(0 To ic): ReDim cir2(0 To ic)
) B' ` a4 C1 o0 V/ |* E ReDim blk1(0 To ic): ReDim blk2(0 To ic)1 S7 [4 N. u& [# r
With ssetObj
" y: Q" q- I, s1 R* X2 v; C$ Q For i = 0 To ic& y3 F6 B4 G; {8 C2 d5 ~
EntName(i) = ssetObj.Item(i).ObjectName
# ?& M! H y& j Select Case EntName(i)6 C1 T) c% a- U& ^0 M
Case "AcDbLine"
# k# l: a8 Q3 | line1(i) = .Item(i).StartPoint
9 U ^- R' I+ j2 W' c/ H+ { line2(i) = .Item(i).EndPoint1 n+ l' j1 o8 q& D0 T2 ~- a8 y+ ~
line3(i) = .Item(i).Angle0 M1 h* W8 a% c9 d. @9 E
Case "AcDbCircle"- {- [+ h& X6 B9 ~
cir1(i) = .Item(i).Center
, Q5 N9 p( t( w- g cir2(i) = Int(.Item(i).Radius * 1000) / 1000
& i: D1 {7 p+ K Case "AcDbArc"
% Y# F6 c; | w- g4 ] arc1(i) = .Item(i).Center# E9 M, ?$ Z% T
arc2(i) = Int(.Item(i).StartAngle * 1000) / 10008 E$ {4 g9 q4 e4 c/ N+ e' V
arc3(i) = Int(.Item(i).EndAngle * 1000) / 1000
0 \9 f( o3 u/ U. I" \$ J arc4(i) = Int(.Item(i).Radius * 1000) / 10001 `# ?+ C, U: C: x, @- K) O3 O9 p* [
Case "AcDbBlockReference"
) ]# Z6 ]2 |& @* A8 t" }& P blk1(i) = .Item(i).InsertionPoint' K; R" w" t4 R$ s, ~) I8 \
blk2(i) = .Item(i).Name
2 D# J* U( w5 s5 c End Select. g2 C( N0 \: X' i; G- \5 e
( a3 ]) f) C- z8 u7 j9 w& I6 k. o Next i& r' y) d3 w$ {5 j. [6 U
+ G) \; @; B6 ?0 X% v/ `
For i = 0 To ic - 1
, M6 h8 Y+ o# g" B7 e* n id1 = EntName(i)
: @7 l! _! m' _" Z For j = i + 1 To ic
& h. q) g: o# m: G j id2 = EntName(j)/ [* b3 I9 \. \! @6 Z; K
If id1 = id2 Then
% Y: Y, [# ~4 X6 `4 z Select Case id13 |) M; q! p: U) H; D
Case "AcDbLine"; ~" x5 P7 y+ L+ t0 w1 L p0 z
pt1 = line1(i). x) g$ W& _3 z: C- o' f
pt2 = line2(i)- f. g2 p0 U+ |# w* @
dege1 = line3(i)1 G9 p/ o( L7 H; i+ ]! |" }/ p) \
pt10 = line1(j)
8 W- g% W0 q ]2 | pt20 = line2(j)
: z" i, _, B8 `: c7 H( h9 t7 { dege2 = line3(j)
S |3 o/ Y* G0 p/ d) E0 p* P, z# L If Abs(pt1(0) - pt10(0)) < 0.01 And Abs(pt1(1) - pt10(1)) < 0.01 And _3 R$ k7 c$ g; f: Q% |$ p3 ?' E
Abs(pt2(0) - pt20(0)) < 0.01 And Abs(pt2(1) - pt20(1)) < 0.01 Then# X8 E R/ z S, f" D
.Item(i).Delete
9 G2 l+ [. }2 q& a/ _ Exit For
# Q2 J% l" i$ I3 R% l4 V End If1 c) O# Q/ U. h
If Int(Abs(dege1 - dege2) * 10000 + 0.5) / 10000 = 3.1416 Then% b* `9 D0 z- ~ Y s: n8 ~" T
If Abs(pt1(0) - pt20(0)) < 0.01 And Abs(pt1(1) - pt20(1)) < 0.01 And _3 g, X# M$ v4 ~ H G0 ]
Abs(pt2(0) - pt10(0)) < 0.01 And Abs(pt2(1) - pt10(1)) < 0.01 Then
" g4 D/ G& B( V: M* {4 a5 t# p .Item(i).Delete
+ L2 ]- K' ?# j3 m) a, R Exit For
7 H+ U3 }/ @3 U' b. p End If K9 w! [; X/ [6 U% `& b
End If! b6 z( O$ G- A% g3 D' b
Case "AcDbCircle"
$ O- ?0 J5 G! V, T8 ^7 A( H pt1 = cir1(i)
' u0 X$ E' @7 f" R' u5 {# A4 p+ V3 g8 W4 D Yuanr = cir2(i)8 n" @, B7 a: o7 n
pt2 = cir1(j)
9 `& }/ Y0 N! Q( |" v- ^ yuanr2 = cir2(j)
8 a2 W& A. V( v4 Q1 r: Q If Sqr((pt1(0) - pt2(0)) ^ 2 + (pt1(1) - pt2(1)) ^ 2) < 0.01 And Yuanr = yuanr2 Then
9 G+ D$ j$ s/ U s .Item(i).Delete7 ?" }5 `5 y. E. |5 U' G- ~
Exit For
, n. H: f) n: S Else
( {. L6 a ^! ]) M8 m! k2 C4 ^! O8 x If Sqr((pt1(0) - pt2(0)) ^ 2 + (pt1(1) - pt2(1)) ^ 2) < 8 Then4 h% K( ~- ?+ a# ~
.Item(i).color = acGreen
! i b- `! \; H) R End If
7 }. V# W6 z6 b( O" x End If# K+ O4 ^' f6 ~* w# e5 k+ C! P
Case "AcDbArc"% r, I( m: z" s. R
pt1 = arc1(i)9 Z; R# F0 U* l5 T% n
dege1 = arc2(i) D6 u9 X$ o, i, l
dege2 = arc3(i)
e7 \3 |4 ^! ]4 I9 }. R5 M1 m: w& n Yuanr = arc4(i)
6 Z. c+ X- |. u, f; K+ j9 M pt2 = arc1(j)0 L5 s- r: I. K- O2 i, d5 Z8 |
dege3 = arc2(j)# f( y b$ _2 ?5 C) Y6 k- ?
dege4 = arc3(j)
% z* }) W7 O9 p4 h& M yuanr2 = arc4(j)
% Z) L- M' a' W9 U" h2 v2 J If Abs(pt1(0) - pt2(0)) < 0.01 And Abs(pt1(1) - pt2(1)) < 0.01 And Yuanr = yuanr2 _& [" q9 c5 m+ {: f7 p6 l
And dege1 = dege3 And dege2 = dege4 Then
6 o. L0 X$ o% _: i- O" L* z0 d .Item(i).Delete; U6 Z* }1 x" v6 z' k
Exit For+ j; e: |! z/ Y9 j, p- c
End If
3 X9 L5 T7 ^. i: L' [9 q# n- K Case "AcDbBlockReference"
' l9 K0 T, @, L+ _; n5 B pt1 = blk1(i)% V0 p; G8 p+ S2 y
str1 = blk2(i)
" q9 A* h7 e0 _) \" X* Q pt2 = blk1(j)9 `6 a( \7 k @. ]
str2 = blk2(j)+ G$ }1 Y1 H- X3 T
If Abs(pt1(0) - pt2(0)) < 0.01 And Abs(pt1(1) - pt2(1)) < 0.01 And _
# J% M* N$ n+ z/ _5 D Trim(str1) = Trim(str2) Then2 @7 |/ _3 i$ J
.Item(i).Delete, W( L4 k9 G! M* T1 [/ b
Exit For
. K: ~/ t1 y2 ^7 A7 w End If
) p5 M6 x8 {4 U' |- {% _ [2 |2 a End Select
) D) w; q9 R1 x1 Y End If, Y1 G4 E0 L* r# B6 R- f6 F
Next j) N3 D, I0 y6 a
Next i1 U- @* _& X) ~ l0 I# d+ _/ l. B4 s
End With9 D9 A7 m- R2 u( {/ P$ A
' MsgBox "删除重复完成!"
9 I5 A4 r) M" }9 H( x GoTo ccc2
7 U0 u9 I! O8 m# K, ^" |, xccc1: MsgBox "有错!!!"0 P; I" P% Q3 g' i" n
ccc2: 'ssetObj.Delete) }- Y$ Q+ A6 C
d. @/ B/ v1 ~% w# o; Z$ c End Sub
' i) r* G# k5 z
& ~- z# f( \2 Z7 ?+ ] Public Function Clamp100(a1 As Double) As Double '判断块存在不存在,存在=100,不存在=02 A. [2 N) G1 e( ^, k7 p6 P
Dim p1(0 To 2) As Double '交叉选择的左下角点* s5 B' l- X1 J9 N! [
Dim p2(0 To 2) As Double '交叉选择的右上角点
% j0 `8 G6 D, _, b8 n( y+ K Dim ssetObj As AcadSelectionSet4 F( i& W v* ?& v6 b1 ]/ N
Dim ic As Integer, j As Integer) w8 q' F4 ~( v4 D0 D3 Q! q
ThisDrawing.SelectionSets("SSSS").Delete5 X1 \! G" A, _8 q
Set ssetObj = ThisDrawing.SelectionSets.Add("SSSS")
* I, G2 ?& t5 x- B) @7 w- N6 O p1(0) = a1 - 15: p1(1) = -25: p1(2) = 0/ f8 c! N9 Z( O: h6 ?% y
p2(0) = a1 + 15: p2(1) = -5: p2(2) = 05 P$ L% Q* a$ X5 l6 R& g3 W
ssetObj.Select acSelectionSetWindow, p1, p2% C* Z$ g' _: p6 j$ f! ~0 L8 o9 a
For j = 0 To ssetObj.Count - 1' X q+ i0 o( ~3 M
ssetObj.Item(j).color = acGreen E& _) A# y2 j6 O# G0 R6 B9 u1 @
ssetObj.Item(j).Update
4 l/ a7 G8 n/ n4 T2 j/ J Next j1 H) a c& o* f" ^5 z/ M8 l& U
Clamp100 = ssetObj.Count: _+ x, S7 f' F+ q/ y
End Function0 }& x1 N" t) ?
& _# _+ l4 l3 n7 A
/ j: w3 Z: F& c6 P2 s
) B0 Q( ]6 a L9 Z" \
, l. `! ?8 p( O$ a看不太懂 不过 我在这里多学学 应该没问题的 嘿嘿 |
|