|
5#
發(fā)表于 2024-2-8 18:18:18
|
只看該作者
Sub creatEndRect()1 W* ^5 l3 v# H" h& G
1 I! O6 [4 L: N4 p. {+ z) s
Dim line2 As AcadLine' k0 ]+ y, q! H
ThisDrawing.Utility.GetEntity line2, basePnt, "Select an line:"
3 _8 P( Y- L5 }9 b1 c3 Y
- f6 U# @9 P- E e/ g# t' C Dim p19 ]5 s* r& Y) I. L# J
p1 = line2.startPoint& D1 A }' B5 t/ a& ], r4 `
Dim p2
e! l) j* {, o M/ u6 t: n, o p2 = line2.endPoint- y& C( y# {5 _
0 F0 |$ h% G' F( J: k5 O
Dim angle2 As Double
2 c- |% V+ Y/ Q1 F# L angle2 = line2.angle4 k, C1 @4 Q) f M0 l
% j# m$ r1 g; O1 N
Dim pts1(0 To 7) As Double
& @9 w+ u! y: Z! {! f Dim pts2(0 To 7) As Double. G Y2 f& N: S9 Y
8 e9 E5 B- d: h8 g% V2 ^; U pts1(0) = CDbl(p1(0)) + 0.5 * Sin(angle2): pts1(1) = CDbl(p1(1)) - 0.5 * Cos(angle2)
! J7 i# H+ V9 r% z" A: V pts1(2) = pts1(0) + 5 * Cos(angle2): pts1(3) = pts1(1) + 5 * Sin(angle2)
; G; u/ j: u/ f/ u7 L pts1(4) = pts1(2) - 1 * Sin(angle2): pts1(5) = pts1(3) + 1 * Cos(angle2)$ b; u/ Q- w5 p
pts1(6) = pts1(4) - 5 * Cos(angle2): pts1(7) = pts1(5) - 5 * Sin(angle2) w( q# |: B( h- ~ }, y
* n) I7 D9 N$ R' w& `4 a5 N
pts2(0) = CDbl(p2(0)) + 0.5 * Sin(angle2): pts2(1) = CDbl(p2(1)) - 0.5 * Cos(angle2)- z( J* S4 D, O& a9 i
pts2(2) = pts2(0) - 5 * Cos(angle2): pts2(3) = pts2(1) - 5 * Sin(angle2), k& ~6 ?. @# |6 R
pts2(4) = pts2(2) - 1 * Sin(angle2): pts2(5) = pts2(3) + 1 * Cos(angle2)2 `& O; Q) s5 C
pts2(6) = pts2(4) + 5 * Cos(angle2): pts2(7) = pts2(5) + 5 * Sin(angle2)$ p( r" _* w" }( I/ R$ C" ]
" @4 j" e0 x( L7 R
Dim pl0 As AcadLWPolyline/ h% V w; M$ e, |- Z' t! B4 G% g
Set pl0 = ThisDrawing.ModelSpace.AddLightWeightPolyline(pts1)+ z* {; V: x" ]' | H
Dim pl1 As AcadLWPolyline
1 C- L5 ^/ d9 S. r Set pl1 = ThisDrawing.ModelSpace.AddLightWeightPolyline(pts2)
/ U2 d- {8 L6 o% V1 A% N5 R& K! _8 }6 F" n) p
pl0.Closed = True
1 e4 I! y% R2 Q9 y! t! F pl1.Closed = True/ w A$ c, ~/ W8 s. l# n. W" ]
+ r! w# A1 y6 s5 R& U1 e& E4 S
End Sub |
|