|
|

楼主 |
发表于 2009-10-22 12:55:03
|
显示全部楼层
来自: 中国湖北十堰
本来想晚上回来在试试的
& m0 k. [$ ]0 | ~1 R, r但是现在不试睡不着 3 V! V0 Q6 t. ]/ h" f! F
嘿嘿
k: Z7 B2 R3 ]% H8 m h7 N0 C7 e& a
试了试, M j, Y; U# n6 U% i4 w
谢谢版主 打开了那个文件
, P7 P/ j9 d) N! Q下面是代码 b8 O- N# Y0 k1 ~, R' w
'Declare Function GS_MHDog Lib "win32dll.dll" (DogData As MH_DLL_PARA) As Long, A) I- V/ d7 x2 {: s! [
'Declare Function InstDrv Lib "RCMicroDogSetup.dll" Alias "InstDriver" (ByVal a As Integer) As Integer7 ?2 E3 w' Y% ^/ W: v! X) d
'Declare Function UninstDrv Lib "RCMicroDogSetup.dll" Alias "UninstallDriver" (ByVal a As Integer) As Integer8 c( K8 o3 k4 z% i3 E; y! S
'Declare Function GetDogDriverInfo Lib "RCMicroDogSetup.dll" () As Long/ m+ [7 }; @/ [6 e" V9 s3 M
'Declare Sub DriverDialog Lib "RCMicroDogSetup.dll" ()
, S9 U& D+ ~2 R8 j1 `( {'Declare Function NotifyPullOutAndPlugInUsbDog Lib "RCMicroDogSetup.dll" (ByVal a As Integer) As Integer
+ Z& I6 t( A) N9 Y; V& m7 f2 K' z/ k& y# }9 R
'Declare Function yy Lib "jmcar.dll" () As Long
& j0 @+ I$ g- s; O9 G/ p1 Y! g'Public xxx As New CAMZDSHXJ
2 ?4 L' p& a: [) qConst SYNCHRONIZE = &H100000
! Q4 e4 H9 H6 pConst INFINITE = &HFFFFFFFF) {3 v+ ^- _5 n2 v% q
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long* @6 g, C' L; p5 M& ?5 J
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
: ^% q4 {% q# |4 g/ z5 R2 _Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
) A% q) T, U XPrivate Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long7 F/ w# {: ~& a. ]1 [( x7 U, @( O. ^
8 @* H0 q* }) V0 {( |+ |/ \Public Function getmac() As String% w0 ?2 L, H% l+ x
Dim retval( w! p6 o0 H |
Dim pId As Long, pHnd As Long ' 分别声明 Process Id 及 Process Handle 变数
! f# `& ?) ` w1 u" F- V; R* { Dim MYSTR, lstr As String- Q0 p/ o# B7 u1 F* g6 o
If Dir("D:\cnc\hxj1.txt") = "" Then
& G+ z& @9 f* C6 k Else2 g0 W6 b; s7 G F( {* U6 o
Kill "d:\cnc\hxj1.txt "
+ Y' u7 Z2 o* a6 p End If
; u4 J7 M. I. W1 V( Y: F1 I3 w# n) ~ pId = Shell("cmd /C ipconfig /all > D:\CNC\hxj1.txt ", 0) ' Shell 传回 Process Id
6 O$ f5 m4 I$ K W pHnd = OpenProcess(SYNCHRONIZE, 0, pId) ' 取得 Process Handle. n1 c0 Y$ O; v3 U( B0 o
If pHnd <> 0 Then
+ Z5 b+ |1 {, \# H3 }- l; W5 E" _ Call WaitForSingleObject(pHnd, INFINITE) ' 无限等待,直到程序结束7 y0 `( A( _1 F9 f X- W' P
Call CloseHandle(pHnd)" k0 M# o: @- m; |/ ]
End If! c7 ]& \% u! L( Y1 L
Close; X, q" t3 q6 g* x, t, s
Open "d:\cnc\hxj1.txt " For Input As #3
! W8 N- F- ?5 K' @ Do While Not EOF(3)
; f& J K5 @# q J) Y- V( T0 i, n Line Input #3, lstr, a8 J# l9 @4 o) H. I8 }: }. \
If InStr(lstr, "Physical Address") > 1 Then" U' S2 W; V! c- q S W
MYSTR = Split(lstr, ":", 2, 1)- k& l' d: [: q5 j/ ^: ^* J% i% [
getmac = MYSTR(1)
; n- x+ T( n: T- ^3 p" n, M Exit Do
: L. U2 I n* w End If" v2 B9 Z( {7 q
Loop" `; ~; ?% G' [
Close
, @! f6 U6 ^0 I2 c+ PEnd Function7 s7 m' Z: @3 J* b7 N& v8 N& B3 o
Public Sub DelDoubleALL() '删除重复图素
: P/ N. ~7 A' D/ ~+ g$ }9 R( v Dim i, j, k As Integer
9 M' s7 \+ I( c8 B! u Dim ssetObj As AcadSelectionSet
! A. f* O6 G0 s8 H$ M. W- C Dim dege1 As Double, dege2 As Double
g" D: s' v& }7 k Dim dege3 As Double, dege4 As Double; E) c* t( X# \# p' T$ f" K+ d
Dim pt1 As Variant, pt2 As Variant, Yuanr As Double, yuanr2 As Double9 a2 L) V' t' j. X& |
Dim pt10 As Variant, pt20 As Variant, Yuanr1 As Double
# U5 g& e! T! }+ r Dim ic As Integer
7 p% c' |' G$ v4 D; x5 X Dim str1 As String, str2 As String, id1 As String, id2 As String
+ }* w6 y$ l% J- F7 H2 n Dim EntName() As String, line1() As Variant, line2() As Variant
* N' ~' S' q8 \5 {: j- ? Dim line3() As Double% g" e) b) ]8 X! E6 o z- U, [
Dim arc1() As Variant, arc2() As Double, arc3() As Double, arc4() As Double
8 i3 E- d/ |( d Q6 o% E/ o" H Dim cir1() As Variant, cir2() As Double, blk1() As Variant7 y2 e- @: B" w. Y4 {
Dim blk2() As String
0 U) F: J. O/ B- j ic = ThisDrawing.SelectionSets.Count '选择集的个数( u% |; |/ Y. ^1 f
If ic > 0 Then
. h0 U; J3 F4 P/ ~ For i = ic - 1 To 0 Step -1" q! i m0 Q/ }" c" B
Set ssetObj = ThisDrawing.SelectionSets(i)
# S. }& }4 V1 c If ssetObj.Name = "SSSS" Then ssetObj.Delete '存在该选择集删除它
# m6 C' ?8 T4 K: C- M2 h; }; O8 W Next, m+ E* i1 }# A. K' j' _* b1 {
End If
2 _6 {+ C; P9 L5 Y4 ? Set ssetObj = ThisDrawing.SelectionSets.Add("SSSS")! Y7 _' m, e- ]& \1 a1 u
' Add objects to a selection set by prompting user to select on the screen
: y9 [" B" T+ r! R3 o+ V3 ]' ssetObj.SelectOnScreen
- U6 x1 d: u; |" Q ssetObj.Select acSelectionSetAll '把全部图形加入选择集
: p" w, V9 J: D; r1 C8 Z) G' sele1.Select acSelectionSetAll, , , ft, fd '层选择/ V% U* n6 W, j6 u) r# O
On Error GoTo ccc1
4 J% r; C9 \+ P+ F ic = ssetObj.Count - 1
8 F' B, _ R7 O$ z' u If ic < 1 Then '选择集孔或图素小于2则退出& K1 V$ E# n' P
Exit Sub t/ Y/ s* V$ B/ J
End If
$ k; j' Y% }! R ReDim EntName(0 To ic)5 Q" R) ?' [' Q/ g2 ?$ C/ E
ReDim line1(0 To ic): ReDim line2(0 To ic): ReDim line3(0 To ic)
6 Q: k& O9 r/ Y2 T6 k; [ ReDim arc1(0 To ic): ReDim arc2(0 To ic): ReDim arc3(0 To ic)
' v! d+ s) V- A2 y0 G- f ReDim arc4(0 To ic)8 M/ [% M, E2 H( t# j
ReDim cir1(0 To ic): ReDim cir2(0 To ic)# e. x5 @8 x: i! |9 o+ h1 j
ReDim blk1(0 To ic): ReDim blk2(0 To ic)7 ~9 H: P! ]& A, V
With ssetObj
% l7 `! x2 v: Q9 D8 @ For i = 0 To ic; i+ } ~2 D5 w& t- n; v
EntName(i) = ssetObj.Item(i).ObjectName
& \+ u3 I t, v+ o2 r" I% J* b( R Select Case EntName(i)! \: N" v6 D* v# Z1 L/ K
Case "AcDbLine"
' h- r' f' U7 C _ line1(i) = .Item(i).StartPoint
7 g; Q6 @8 B, a6 p* i line2(i) = .Item(i).EndPoint4 B( G9 |: j' [5 m$ h, a
line3(i) = .Item(i).Angle
2 P9 o# P9 K7 d Case "AcDbCircle") M c- V4 w5 O8 y
cir1(i) = .Item(i).Center
* O+ n) }8 x, z$ G5 z cir2(i) = Int(.Item(i).Radius * 1000) / 10009 z& Y M$ W2 t; N) }
Case "AcDbArc"
& Y6 \! |: V* W6 a! Z arc1(i) = .Item(i).Center
+ K- ?- d/ f9 D7 V arc2(i) = Int(.Item(i).StartAngle * 1000) / 10009 P; O& D9 B& B, D
arc3(i) = Int(.Item(i).EndAngle * 1000) / 1000
h0 w; P8 J& t s% k arc4(i) = Int(.Item(i).Radius * 1000) / 1000
8 R7 J v3 E* a2 g' [ Case "AcDbBlockReference"
L& T# q# |! D! w* L+ E; j blk1(i) = .Item(i).InsertionPoint0 G+ {3 p/ z1 }! J6 h
blk2(i) = .Item(i).Name
) R$ Y; W! ^& \8 Z7 M8 B1 } End Select
$ J/ @2 _6 f" O m% n ; Y4 ?) R4 M" I2 t* G
Next i
! A) m* W- o; y( \9 L% q* L* c! q% U0 M
For i = 0 To ic - 1! E5 m7 p1 w( T& m4 U, Q% K
id1 = EntName(i). a# T$ W1 s8 D
For j = i + 1 To ic& P! P& \5 ], |
id2 = EntName(j) T% ]7 C' T, p) D# @1 |+ @$ k* ?
If id1 = id2 Then4 C% V- Z% t) I( D4 y+ X
Select Case id1% Q" C2 P" b3 |3 E
Case "AcDbLine"
6 G- c9 I0 G8 g+ C% w pt1 = line1(i)4 X3 I& F1 Y ]$ ]5 B
pt2 = line2(i)
1 n/ j+ C: Y1 A( X) w( e) ^ dege1 = line3(i): a0 F* ]- j" v( C: F% @
pt10 = line1(j)
9 v4 x3 B8 q9 r# V* \ pt20 = line2(j)2 m! d, S- R) t/ g
dege2 = line3(j)4 u) h; r' N& C. ]/ {' P( A& x
If Abs(pt1(0) - pt10(0)) < 0.01 And Abs(pt1(1) - pt10(1)) < 0.01 And _ r& m7 m/ a6 J- E) {
Abs(pt2(0) - pt20(0)) < 0.01 And Abs(pt2(1) - pt20(1)) < 0.01 Then( m$ @$ c7 m) r# I( q6 c- I P' I
.Item(i).Delete
% s+ M5 Y$ v& \ Exit For, V) b" P' Q# N' n
End If) A" u% n: `$ H! D9 [) v3 p
If Int(Abs(dege1 - dege2) * 10000 + 0.5) / 10000 = 3.1416 Then
% D/ |" Y+ T7 X& j; Q1 n, t If Abs(pt1(0) - pt20(0)) < 0.01 And Abs(pt1(1) - pt20(1)) < 0.01 And _ v( z9 l3 c- U6 v$ D
Abs(pt2(0) - pt10(0)) < 0.01 And Abs(pt2(1) - pt10(1)) < 0.01 Then
, f/ O3 I) Y' u U .Item(i).Delete
' ]. A9 |0 o2 |" c1 I& h Exit For
+ ~5 u" T3 I1 [* \( N End If
7 n* G4 q0 a/ {8 ~ End If3 ?( |" R, r! O. t0 Y* p
Case "AcDbCircle"7 A1 S+ z+ |6 D% ^
pt1 = cir1(i)
% \! S M# L4 c% J4 E5 K$ J. N% x0 z Yuanr = cir2(i)
& k; F, q, t+ _ pt2 = cir1(j)9 ^% V6 B4 G6 x Y! N4 a. @
yuanr2 = cir2(j)
+ S4 |& U7 p% A5 } If Sqr((pt1(0) - pt2(0)) ^ 2 + (pt1(1) - pt2(1)) ^ 2) < 0.01 And Yuanr = yuanr2 Then
) D; w" v$ b( B g* \0 c .Item(i).Delete5 H: x& A* ?2 v! Q* _8 I# \, e
Exit For
7 X- W* y. Y0 C+ l1 B Else5 c4 p: F( |) | w
If Sqr((pt1(0) - pt2(0)) ^ 2 + (pt1(1) - pt2(1)) ^ 2) < 8 Then# k# P4 j; i' |4 i7 X) E
.Item(i).color = acGreen, F" @" t! I5 S3 w
End If
0 t) W% |5 Q$ b* [0 ~0 x) u End If( N( _0 [0 j; `3 _. ]
Case "AcDbArc"* _) y+ a+ m1 V4 e9 U `6 r* G
pt1 = arc1(i)2 n# [ g% l! f% J7 X& R' u
dege1 = arc2(i)
. Z/ A' e; Y& Z: ` dege2 = arc3(i)
) u/ a J7 ^5 B+ B Yuanr = arc4(i)! u1 E0 \) _% t+ s& G. g
pt2 = arc1(j)
8 c# r4 Q4 Y, A dege3 = arc2(j)
2 _% g. N1 Y7 y z4 J4 y0 I+ q dege4 = arc3(j)9 ^7 E; i; g1 A7 m& V7 }" ^
yuanr2 = arc4(j)
) }" L2 d9 x: f" [: X9 W( @. g5 t If Abs(pt1(0) - pt2(0)) < 0.01 And Abs(pt1(1) - pt2(1)) < 0.01 And Yuanr = yuanr2 _3 m; |; d- U! |5 ^
And dege1 = dege3 And dege2 = dege4 Then7 X+ \* i' w. |3 T6 E; S. f
.Item(i).Delete& n6 c. \8 o% [/ T2 |
Exit For
- X2 V6 d# c' R B$ P( p End If- c2 s6 |% D7 `7 g: h
Case "AcDbBlockReference"9 h; r% g# g, _- a* K$ b
pt1 = blk1(i)
4 _3 B5 m% `. w str1 = blk2(i)
$ o6 F/ L3 W; @4 p2 { pt2 = blk1(j)% K. |: f' C$ ?# Y& @+ q$ {. @
str2 = blk2(j)
% T0 F( y' {* D* g If Abs(pt1(0) - pt2(0)) < 0.01 And Abs(pt1(1) - pt2(1)) < 0.01 And _: X7 O; g" z7 P- b9 u
Trim(str1) = Trim(str2) Then
* Y! W3 X3 T! H | .Item(i).Delete7 c& t4 G5 r8 I: m
Exit For! q" s. W# E5 v
End If( G4 f; Y/ N/ ~* M
End Select
8 d7 h; u2 |) c$ J( a9 ` End If" _) p" M/ j7 w
Next j& ^) E+ u. u! l3 w8 O) I
Next i
: C. W) @1 E" Z6 y: W, O End With
; R+ B& I4 X: N; j' MsgBox "删除重复完成!"/ @% g1 V& g+ C {6 ?6 h+ l; M d
GoTo ccc2/ |& q- w1 T! p
ccc1: MsgBox "有错!!!"
$ N; T$ x4 b. \6 Cccc2: 'ssetObj.Delete3 L4 U2 [2 P& v& L- ?4 i
/ K9 v1 }8 |5 S4 [5 Z
End Sub
+ I* o: z( D. Z) n/ j/ `; v: X; C" ~. v( ^8 l
Public Function Clamp100(a1 As Double) As Double '判断块存在不存在,存在=100,不存在=0
" }+ {" h: u/ y' F" q Dim p1(0 To 2) As Double '交叉选择的左下角点6 I0 i& t: W, S l
Dim p2(0 To 2) As Double '交叉选择的右上角点* F% |" \0 Y5 ^
Dim ssetObj As AcadSelectionSet% l# W+ t& K0 L6 Q0 ]! I# Y
Dim ic As Integer, j As Integer
) U: h$ W- z5 K: ]& L. _4 z ThisDrawing.SelectionSets("SSSS").Delete- @( N: @5 r; j: S
Set ssetObj = ThisDrawing.SelectionSets.Add("SSSS")
# Q1 z( t9 l. K5 \1 P p1(0) = a1 - 15: p1(1) = -25: p1(2) = 0
2 w; w _4 Y+ O( G; v6 \ p2(0) = a1 + 15: p2(1) = -5: p2(2) = 0
, q5 [+ d' g; h" }& g" a8 n9 R6 ] ssetObj.Select acSelectionSetWindow, p1, p26 h7 j1 T' w7 T v
For j = 0 To ssetObj.Count - 1/ M" h4 S+ u# U
ssetObj.Item(j).color = acGreen
: `2 B9 c+ {; K) j% ` ssetObj.Item(j).Update4 g: @( G3 y/ i2 I6 n4 b
Next j# _8 j I7 r$ w& u4 q
Clamp100 = ssetObj.Count
6 s: m+ r, A9 K8 v {% y; b tEnd Function% r; D* R+ Q3 {* t6 L) B7 {
, u0 W! s: J" r# d( q/ P+ h6 ]# N
" L- d, J0 t F! B3 `1 s' G* C/ F6 X" s$ P- |
% s2 l @+ ~) e/ b: d4 w$ |看不太懂 不过 我在这里多学学 应该没问题的 嘿嘿 |
|