|
' ug刻字源码 +QQ 609719845: h2 Q) j+ C8 E9 m% \
' into geometry using a true type font and$ j8 J, m' E& Y' [0 E
' extrude the result' t! {1 V* a1 z4 \1 Y6 G' e
, x0 g, _! f8 G! E/ L8 [
Option Strict On6 b1 k4 j* I, t
: `* C' R7 f8 b4 W- v) AImports System
) F3 l& W1 b# ?& S P5 EImports System.Drawing+ |0 j! i; h5 g" k7 k; k
Imports System.Drawing.Drawing2D
4 J7 ~9 q) c7 M! S# nImports System.Windows.Forms
" J. E8 A, I5 {$ J V* F1 tImports System.Collections3 n2 ~" L9 i! u+ u! i
Imports NXOpen5 S3 r7 ^( R- p1 e* |* d
Imports NXOpen.Features+ K# {! u$ y) \) ]4 ~4 O
Imports NXOpen.UF' W5 [7 j1 E1 L' e9 e
Imports NXOpen.Utilities; z8 n% T! L0 n/ U
Imports NXOpenUI z3 m% L% H/ N0 M2 v& ?
" c- A, k; h! X0 R: r# EModule DrawText0 c/ W: T- m8 t# s, c; _3 n1 C
8 ?% y/ f+ c! w Private sess As Session" C/ J+ ~) S2 K, R4 R. n+ x
Private ufSess As UFSession
' s8 X7 E1 c/ }' m+ E& {( D5 w& c/ X Private origin(2) As Double) S+ @! [8 t* @& N7 i6 ^
Private path As GraphicsPath/ j7 r7 p3 c1 E5 u$ f
Private text As String
% S* C, [- p/ _* {5 \ Private font As font" N: s5 |; Y/ k0 `
Private curves As New ArrayList! S# f1 ^* B) s9 O* r. T
Private sketch1 As sketch- L$ q0 z% M0 w" G; `
Private thickness As String. s+ B% a [1 Q
Private undoMarkId As Session.UndoMarkId! D7 D8 S1 a- ]1 u3 o3 k
; M' r4 U9 B& g* \ ?) u; l7 ? ' Prompt the user to select a font.# M" B" T2 }, u! R
' Return True if successful
7 Z* _# M/ k5 ~9 F/ K% r0 s+ j' T ' The Module level variable 'font' is set to the resulting font.4 ?! @: ~) N1 N& {: E3 W
Function SelectFont() As Boolean
; @) Z7 f4 p' U+ i# M) {* k Dim fontDlg As FontDialog = New FontDialog
, V1 A8 c; H- g* m
- Y4 r6 s0 m4 e- |1 e/ E+ t+ Z2 A9 { SelectFont = False, u3 f. B1 x1 j/ L2 m0 K
If fontDlg.ShowDialog() = DialogResult.OK Then' t! d( b* i0 V& |
font = fontDlg.Font" h& Q+ {+ Z5 P% z0 q1 w
SelectFont = True( z7 s+ D/ k* M( t
End If3 q4 F( K2 E# R( Y n
End Function& _; m8 o2 F# F; A7 J, F
' Prompt the user to select a screen position) x/ _7 b' |3 l: a9 K8 h7 H. L
' Return True if successful
9 v) h% y# D' p/ [0 E! M8 u ' The Module level variable 'origin' is set to the resulting point.0 q- a4 B- L S$ ]6 \9 N- Z% K
Function SelectPosition() As Boolean
, A' |. M) |' a1 q. ` Dim view As Tag
( k; L3 X% E- A0 I4 a Dim response As Integer
7 p, h( l- J: j: G: N o% X
8 c9 k. K* k5 A3 T i5 M7 [$ b ufSess.Ui.LockUGAccess(UFConstants.UF_UI_FROM_CUSTOM)
/ `% Y% {+ f. [6 B. _$ j8 i SelectPosition = False
, X9 v* N* ~" P9 z% q7 W& Q. f Try
3 v8 B, p, D# L# E3 y: `& A" j ufSess.Ui.SpecifyScreenPosition("选择字体", Nothing, IntPtr.Zero, origin, view, response); H. Q3 a" V8 z3 {( ^; |; l
If response = UFConstants.UF_UI_PICK_RESPONSE Then
6 }+ I* Z# E4 B1 W2 x! X6 | SelectPosition = True
4 T) C J" |7 W* p End If, t! t7 v7 M" ~2 G' n( w9 g
Finally
& i! t: M( `4 o! ]* T) } ' Restore UI state always including in case of error.
U7 n! l4 Z0 a8 V8 v ufSess.Ui.UnlockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)
8 Y( I! g+ i% F/ N End Try
$ ]5 a$ w) t/ E6 } N1 V0 N End Function% B( e1 m/ S- q& K, ]# Z
' Prompt the user to input a text string to convert.! w0 u3 l8 q! u7 J# r. l9 B
' Return True if successful6 D) K; K& U( _
' The Module level variable 'text' is set to the resulting string.
, i- H7 i$ _/ h2 i Function SelectText() As Boolean' Z- b# E* B( W: H) d+ k. s
text = NXInputBox.GetInputString("输入文字", "Enter String To Convert")7 C/ [! {+ Q+ Z, B0 ?2 N9 N& b
SelectText = False1 N1 t# ~5 v$ A, m, F
If text.Length <> 0 Then
* x7 L+ i" W5 m SelectText = True
4 X; `2 f }; L4 w) z) n End If+ j1 |" e7 [" |; U7 a
End Function4 l+ ], N& [) o/ }4 z7 e
' Prompt the user to input an expresion text string to convert.9 B H9 B6 M+ D" L! |
' Return True if successful
- D: @2 [0 i* X0 i7 |: y ' The Module level variable 'thickness' is set to the resulting string.
- l" z2 u. V$ a0 p( I D Function SelectThickness() As Boolean
5 D8 S: a& Y: | C. X thickness = NXInputBox.GetInputString("输入高度", "输入高度")( R0 i3 |# O% B o0 `
SelectThickness = False
5 J8 c \/ s, t: `* | If text.Length <> 0 Then) T Q0 D( f6 O: e" ~0 Z
SelectThickness = True6 V& O- J) C; {5 A( R( ]
End If
- g K) t2 d" y3 w End Function
- y# n" h3 D8 F3 y# Q$ S/ Q ' Given a subset of the graphics path between the given indices & u2 L9 P; q6 t2 U% j" ]* l% l
' create lines between the points in the path.
8 ?) I8 m- R! b# z- |$ S$ s) Q8 F5 o ' Assumes that caller has selected an appropriate section of the path.
# ` D! n6 B' O: [# r1 V0 f Sub CreateLinearPath(ByVal startIndex As Integer, ByVal endIndex As Integer)7 C5 S5 }- a6 B: R2 G) a
Dim j As Integer" f3 q& H% J- u3 H1 Q
For j = startIndex To endIndex - 1
/ p$ j5 Q% v' w- U2 e( t9 }8 e+ Q. J2 f Dim stpt As New Point3d
( O" x5 c6 g4 o) ~ Dim endpt As New Point3d% C, h2 J; g* w9 |: a! U. x1 J8 m
stpt.x = path.PathPoints(j).X + origin(0)
8 M: C/ v3 b* K9 B# z& @0 C stpt.y = -path.PathPoints(j).Y + origin(1). K6 @5 x+ I# F9 w) H+ [, F# @3 e2 t# ], s
stpt.z = 09 W% |% Y" R1 h. d. W; R# w
endpt.x = path.PathPoints(j + 1).X + origin(0)/ R& Y X% w* m, A" Y
endpt.y = -path.PathPoints(j + 1).Y + origin(1)
3 g( e+ i; ?' K2 W' \* d; s9 K$ h s endpt.z = 0
' A; S7 e4 h8 ] _# ?- b curves.Add(sess.Parts.Work.Curves.CreateLine(stpt, endpt))7 |, |3 F& q8 g2 D7 Z \4 r
Next2 o+ g+ F/ ?2 U% m" R
End Sub
3 O' o1 t& |( K W4 p2 V ' Given a subset of the graphics path between the given indices % l/ p' u! p8 F. C
' create splines between the points in the path.% E% B6 N! f- b. `$ Y
' The path contains bezier segments and this converts then to B-splines.3 k ?& o: t8 [' Y5 v/ |: @$ l" m. {
' Assumes that caller has selected an appropriate section of the path.7 g( @# V; _: ~' [
Sub CreateSplinePath(ByVal startIndex As Integer, ByVal endIndex As Integer)
1 T8 a: f+ [! q5 f* m1 M Dim j As Integer O3 m- [+ L2 b' C0 a8 n
For j = startIndex To endIndex - 1 Step 3
" R8 d# o3 U. d5 G) n" P$ D Dim poles(3, 3) As Double/ m0 H, L+ i0 y4 u4 q! T
Dim k As Integer. Y+ L5 J% p: c. Q4 ?! F" {0 ~4 O& R
For k = 0 To 3
, _9 \9 R! V+ k9 B" a( F4 U4 [ poles(k, 0) = path.PathPoints(j + k).X + origin(0)
2 S# J5 x- h7 S poles(k, 1) = -path.PathPoints(j + k).Y + origin(1)
5 ~6 p( x6 I) J' [& w( A% T poles(k, 2) = 0+ b N \: [% q
poles(k, 3) = 1
3 s ^% a. n5 E: K7 \ Next. Z$ `8 K* D3 c- Z2 r9 S# q
Dim knots() As Double = {0, 0, 0, 0, 1, 1, 1, 1}! g ^7 r+ K# \' ^' l' M5 n4 u6 _
Dim spl As UFCurve.Spline
6 h9 s7 I6 A6 V- }# k0 O% Q2 ? Dim spline As Tag
9 G/ |5 D! ~; w' y3 E+ q) N Dim num_states As Integer
. ~, c N+ w" w D! `1 }$ H6 I Dim states() As UFCurve.State = Nothing: w! ?7 W; b& M4 }
spl.start_param = 0 D0 B9 t/ n' U! l0 c
spl.end_param = 1
) e6 u5 M' W! g' j* w& }0 E9 O2 c spl.is_rational = 0: W; c7 h" \; c* Z0 Z1 g
spl.num_poles = 4
- S* f4 p* g* F, | spl.order = 4
. Z- ~0 C7 y% I; R2 i/ {/ X spl.knots = knots
* l$ u/ Z+ S6 U6 ^6 `7 Z+ U spl.poles = poles
; Z/ C. V, T: ` F/ Y; j7 e% L ufSess.Curve.CreateSpline(spl, spline, num_states, states)' @. P+ h% t( }3 b/ u, E, \
curves.Add(NXObjectManager.Get(spline))
6 H+ E5 y, e7 `. n$ ] Next, @7 N0 F6 u: m7 \& ~% c
End Sub
9 S+ E- T. u) K: w) k ' Create a sketch and add all curves we've created to it.
$ D V4 l' @6 e$ w9 R ' Most of this was created by recording create a sketch and editting the result.
- q8 t1 y1 }9 G' [, z ' Retries with different sketch names to avoid duplicate names.0 E% f V* k+ n4 I0 `
Sub CreateSketch()' I/ M: r7 L1 a3 f
Dim theSession As Session = Session.GetSession()2 G- \0 \# I I( B/ |' }
Dim workPart As Part = theSession.Parts.Work9 J( J, ]4 h6 Z
Dim displayPart As Part = theSession.Parts.Display% C' h0 N% O2 Q0 C: I3 @
+ [4 K1 s) {2 ~2 }* f, G$ Y C. J Dim markId1 As Session.UndoMarkId
7 h5 K& B, g0 a0 F) D& L0 M, ~ markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")' I* ~% S# o6 n5 p V% p3 v. W5 q
+ e# _1 ]) G* R3 y
Dim nullSketch As Sketch = Nothing" i& l- U7 l) ^9 E& ]# T2 g% t: U
5 V) g1 @, V# r9 M9 Y' |
Dim sketchInPlaceBuilder1 As SketchInPlaceBuilder. H- x# O, y: d6 u k
sketchInPlaceBuilder1 = workPart.Sketches.CreateSketchInPlaceBuilder2(nullSketch)4 [$ k& Q" ~( t2 O% G9 d
1 A& b0 D& \; |- E" w
Dim unit1 As Unit = CType(workPart.UnitCollection.FindObject("Inch"), Unit)
$ J8 n+ P D8 C
" }: q, T, W: U, p/ z& a- B8 h Dim expression1 As Expression
, I* |9 b# n4 p6 Y' f expression1 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)2 Q1 s+ D6 w, d8 o
3 A, R, J$ d- O# j$ h3 {1 Y Dim expression2 As Expression4 c- \ H l4 N8 N3 }6 k, m6 T
expression2 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
& u! }. a; ^4 J4 E. h$ [- ^* U/ v: d+ @7 J6 b" r2 ?
theSession.SetUndoMarkName(markId1, "'Create Sketch Dialog")! K$ r. F ~" Y& \- O$ X: u
2 H/ |1 n- X: _; i! C! { Dim markId2 As Session.UndoMarkId
# y7 u0 ~, m, C4 ], n: D markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Create Sketch")$ e' }# U$ ?, F5 Y
6 I" j8 N; S- ]2 q9 k( u7 ? theSession.DeleteUndoMark(markId2, Nothing)
5 Z: O& n1 G) O0 e: C) \ k2 r$ u G% w6 S& |
Dim markId3 As Session.UndoMarkId9 h5 g- G3 |# A! x, N0 X# @/ r
markId3 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Create Sketch")
$ }, Y; `- G u4 G3 f( x/ j& u& S! E$ M
' Inferring constraints and auto dimensions may take long time and is not really required for drawing text. " ~( f0 u1 t$ b) U
theSession.Preferences.Sketch.CreateInferredConstraints = False
E6 v$ G6 D: }) v) C* v theSession.Preferences.Sketch.ContinuousAutoDimensioning = False
' Y3 l: ?- \! L theSession.Preferences.Sketch.DimensionLabel = Preferences.SketchPreferences.DimensionLabelType.Expression
0 L$ n- w4 z( B; X* m5 ]/ v theSession.Preferences.Sketch.TextSizeFixed = True8 B' k1 o0 f$ j3 n! e9 D4 H& b) w
theSession.Preferences.Sketch.FixedTextSize = 0.12 | _, A$ P. `) h; k& a1 I' ^
theSession.Preferences.Sketch.ConstraintSymbolSize = 3.0
4 p) `1 C& V# { theSession.Preferences.Sketch.DisplayObjectColor = False. T9 G& Z# d$ ^
theSession.Preferences.Sketch.DisplayObjectName = False' a8 t; r1 O: { r0 b& k7 t
$ W, C% ?% z* c Dim nXObject1 As NXObject* { Z0 V3 m1 u7 n8 C" y
nXObject1 = sketchInPlaceBuilder1.Commit()2 o4 a4 f# U3 U' u- k$ Q/ ^
sketch1 = CType(nXObject1, Sketch)
# ~) K: V1 L3 O, S7 i
. q/ M2 ^$ T% ^/ H$ U1 L Dim markId4 As Session.UndoMarkId
- X4 |) X, n. m1 T% T% m markId4 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "update")
5 d8 v% s0 p, m+ z( p2 U2 t/ X! F% Z% Q2 ?# u7 q2 d
Dim nErrs1 As Integer0 C! D# m' T0 J" b
nErrs1 = theSession.UpdateManager.DoUpdate(markId4)
* L* e& M+ W3 F0 ?8 y' A: o/ ^& o
6 g" G A/ _" ?$ y' v- Z5 E sketch1.Activate(sketch.ViewReorient.False)
( l; L' K- G9 Y# f9 O
( m0 a7 u* u/ g' Q- y Dim curve As DisplayableObject
. s5 @* B, U- {. d. r For Each curve In curves- s* \3 |% P2 S& m- r* F
Try
) {& l% @& u/ S( @ sess.ActiveSketch.AddGeometry(curve)
7 [1 Z; a7 t, [' o9 j5 M2 N r Catch ex As Exception1 G3 g4 f! K- q9 v7 J' l
MessageBox.Show("Could not add: " + curve.ToString + " to sketch " + ex.Message)
2 G Y5 t& y, F0 X End Try
4 p- e* n9 D! }* f Next* d) i" C& |# W) K! F- Y4 G
H0 `3 N5 J- K& \ sess.ActiveSketch.Deactivate(sketch.ViewReorient.False, sketch.UpdateLevel.Model)6 g/ P0 q0 q8 M6 W: C
/ O3 L' E) F0 O1 U
theSession.DeleteUndoMark(markId3, Nothing): X! s" ]" w x! S7 `6 G
theSession.SetUndoMarkName(markId1, "Create Sketch")8 v# l1 M w$ H6 q7 X
sketchInPlaceBuilder1.Destroy()5 ?3 I, ]1 V4 ^* U
" `: W" `, i4 M; N! A
Try( R9 `! C" v7 F; }
' 'Expression is still in use." q9 Q( A/ _9 n1 P/ p4 T' @' P
workPart.Expressions.Delete(expression2)( l& X- l) j8 m W$ O9 N4 ?
Catch ex As NXException
/ w6 f. E; R/ N) f ex.AssertErrorCode(1050029)
) y& I$ l& m( t8 t6 i/ E2 g End Try
: g( x" K2 @/ {/ l
3 ?0 _2 G9 p+ P# y% o Try+ g7 I' f& V+ I) m5 Q
' 'Expression is still in use.
1 n; A/ S- s3 F& x: D3 }! ?8 M workPart.Expressions.Delete(expression1)
4 C4 J% l; L9 S1 ]8 W Catch ex As NXException
- a; i3 ]$ _: I ex.AssertErrorCode(1050029)9 _( l3 U' U9 M6 g* W5 D! ?
End Try; o" q2 W1 Y7 t
" A ^5 P# i) s End Sub
4 F: w9 @# E* {: Q( s% g% E ' Extrude the sketch
! V7 h7 i) v7 n" U Sub CreateExtrusion()
3 d# X" M8 I1 y! r# N/ g
0 ]% c! S7 q9 S& V Dim nullFeature As Feature = Nothing
, c2 f5 J! J$ T' Z7 M' ^. E" ~
+ U+ {+ K, L% A( W, b Dim extrudeBuilder1 As Features.ExtrudeBuilder
, |. o# C& K; |# u7 ^9 H) F6 j extrudeBuilder1 = sess.Parts.Work.Features.CreateExtrudeBuilder(nullFeature)
$ M& s( {5 r$ d* `7 z. c( B
& _& m/ q0 p2 p: h9 d/ H Dim section1 As Section
5 z/ c/ P3 x* S5 t! \( c' F% H. W section1 = sess.Parts.Work.Sections.CreateSection(0.000001, 0.001, 0.5)5 E! B* q( j) t7 o7 l! e
- J+ q: ~; j7 d1 ~ Dim featureArray1(0) As Feature; S N" j( J5 a7 {7 k! q
featureArray1(0) = sketch1.Feature
4 A. R: x) d9 y. P2 O Q Dim curveFeatureRule1 As CurveFeatureRule; ^3 @7 a9 T% N( o5 i2 s
curveFeatureRule1 = sess.Parts.Work.ScRuleFactory.CreateRuleCurveFeature(featureArray1) r5 ?5 w; {$ ~+ N, a. n
, A" ?# @1 [/ s1 S1 S E
Dim rules(0) As SelectionIntentRule+ ]' o$ |# |+ g3 J6 P- z6 v
rules(0) = curveFeatureRule1
7 C6 p0 n/ ~, f Dim geoms() As NXObject = sketch1.GetAllGeometry(). }5 N8 c5 t; C) L& k, }
Dim helpPoint As Point3d = New Point3d(0, 0, 0)
6 |5 Y& e' s. Q section1.AddToSection(rules, geoms(0), Nothing, Nothing, helpPoint, Section.Mode.Create)
7 g0 _# f1 N; ]. ~* d- M1 @, r2 I0 h) a& K, X
extrudeBuilder1.Section = section1, q- s$ w. B/ S, f& ~9 D
8 F2 p9 c3 c+ E( Y$ z' a% Y
Dim direction1 As NXOpen.Direction6 t, S# G1 E" [. V" v3 ^
direction1 = sess.Parts.Work.Directions.CreateDirection(sketch1, Sense.Forward, SmartObject.UpdateOption.WithinModeling)) L' X" m, H, K/ L4 j
extrudeBuilder1.Direction = direction1
: A# C- Y: ^1 V3 X# \! m
8 _7 x1 |6 ]6 z) f5 Y8 ^( l n extrudeBuilder1.Limits.StartExtend.Value.RightHandSide = "0"
/ C6 Z8 W- |, J/ D) X$ v extrudeBuilder1.Limits.EndExtend.Value.RightHandSide = thickness
) W' R5 ]1 [3 D1 x; `! ]' L" Q. f/ H- ]4 I a+ ?9 A' `! \' F7 x! c
Dim featureOptions1 As GeometricUtilities.FeatureOptions
6 n! Z& m; U' V% x2 q featureOptions1 = extrudeBuilder1.FeatureOptions
# g% S g/ I/ s# \: d$ W featureOptions1.BodyType = GeometricUtilities.FeatureOptions.BodyStyle.Solid
0 `& y, U2 l; O" O
% ? A* y, F2 \6 P8 i Dim feature5 As Feature" a8 n; F- ^6 U
feature5 = extrudeBuilder1.CommitFeature()
+ ?. ?( @' o' B; e
# H( o$ M- I U" X' _7 F* T extrudeBuilder1.Destroy()
+ Q( M7 ~$ P3 R/ _" B3 t0 `
2 J3 x3 d; V6 k7 G3 y0 W. }+ W End Sub) p& }6 n: _9 L0 e$ G% Y. i7 F6 V. E
' Main routine for this journal
8 A* o4 ]: F- a' K Sub Main()
) w3 R' R$ x( n9 [. u( V8 f# Y, i& q. G sess = Session.GetSession()
/ t% @1 J* i% p* H ufSess = UFSession.GetUFSession()& r) W2 Z- O2 D! O9 ]5 d
! z( U8 J( M0 p! c8 ?# b9 R
If Not SelectFont() Then q& T* L _" Y; r! Y
Return2 ?& h3 f Z. u+ g
End If; @# P9 |' T' l, i5 I9 X3 D2 p+ [: p
If Not SelectText() Then1 T- n# I, T4 c5 r- a
Return
9 R4 }* w% K6 Y0 q/ B" G$ n7 Z End If
7 i6 [% b0 ~1 a; G# F+ U If Not SelectPosition() Then
" m$ z' O, s* S9 F E: J! G6 ^+ M Return4 h7 Q* L o9 S7 |# S
End If
$ C: F @; @- T! z3 e
, g! ?7 I' E0 I2 O undoMarkId = sess.SetUndoMark(Session.MarkVisibility.Visible, "Create geometry from text"), z; D3 p3 g* x2 b/ {
0 h9 i: y+ N4 x8 v: G$ s: z( \( r
path = New GraphicsPath(FillMode.Alternate)8 p% y: z3 u" c% D
Dim zero As New System.Drawing.Point(0, 0), g8 ]; A3 N8 I6 [5 F0 F3 P
Dim format As StringFormat = StringFormat.GenericDefault4 S- w5 C3 |- |& V
path.AddString(text, font.FontFamily, font.Style, font.SizeInPoints, zero, format)
9 m1 p' r5 u1 @$ ?
# @4 e4 J m: s5 n! \ Dim bounds As RectangleF = path.GetBounds()( C7 }( r( u+ @' ^+ s! |7 z
Dim gpi As New GraphicsPathIterator(path)
, k/ Z) | y$ ?% u7 ]9 ^ gpi.Rewind()
# \$ X* @8 f- k0 o
7 C" k \8 r" K, L8 q4 V origin(0) -= bounds.Left
. p# a. U9 @ v2 K" Z2 s origin(1) += bounds.Bottom
( j' a' Q1 q# }4 ~0 w/ `) n H- j9 l a5 q6 i% M9 \7 Y
Dim iSubPath As Integer+ m2 r- l% \; M
Dim subPathCount As Integer = gpi.SubpathCount
1 ]6 c( x7 N2 D5 Q
' z( M- g% ]* U- Y% R/ h: G For iSubPath = 0 To subPathCount - 1+ j: m. F; V- i
Dim mySubPaths As Integer
0 V1 h: L+ k" [. j. W3 W8 ~ Dim IsClosed As Boolean# R/ B* _9 G- p& Z0 _
Dim subPathStartIndex, subPathEndIndex As Integer
/ R% ~$ U% F2 G; c* O! ~ Dim stpt As New Point3d% o6 o i2 M; b3 U( {: ]0 y! A
Dim endpt As New Point3d+ Y, F6 ^- N# d; N$ H
) `! m3 v5 |2 j8 P8 d" w7 L3 F3 V- G. F
mySubPaths = gpi.NextSubpath(subPathStartIndex, subPathEndIndex, IsClosed)" W4 }: e8 f& z- ~) m3 m! O
Dim pointTypeStartIndex, pointTypeEndIndex As Integer2 ?: X; q* C/ S3 T T
Do
6 I7 D' c l" ]6 K0 @5 N Dim subPathPointType As Byte
2 u7 B1 H- W. R Dim numPointsFound As Integer = gpi.NextPathType(subPathPointType, pointTypeStartIndex, pointTypeEndIndex)
, j+ |- m \7 @% M! t0 t! C, s Dim type As PathPointType = CType(subPathPointType, PathPointType)* m# W1 s1 R3 r& v& e
% }' ?8 b, k: ]0 d1 j" b# r% r If type = PathPointType.Line Then' V4 M. w9 R4 Z; {
CreateLinearPath(pointTypeStartIndex, pointTypeEndIndex)
7 |6 G2 i. r( K8 s ElseIf type = PathPointType.Bezier3 Then7 p) ~: _8 n; R
CreateSplinePath(pointTypeStartIndex, pointTypeEndIndex)
: L7 N2 Z1 z9 } v End If, F+ a r% D; G! v4 J% `) b" Z
Loop While subPathEndIndex <> pointTypeEndIndex2 q M/ b5 @2 z1 T& P: `
If IsClosed Then
& e8 i% t0 a" ] m, i! A9 l* e" C stpt.x = path.PathPoints(subPathStartIndex).X + origin(0)
+ W4 m2 n2 p, H stpt.y = -path.PathPoints(subPathStartIndex).Y + origin(1)
/ c$ }& b, q! k5 K5 i! G. a stpt.z = 0) x( m3 t I; T- X
endpt.x = path.PathPoints(subPathEndIndex).X + origin(0)7 @/ `7 H; F$ e6 J' ]8 c1 d( E3 n
endpt.y = -path.PathPoints(subPathEndIndex).Y + origin(1)
1 {) H$ X f+ T+ W0 \) X endpt.z = 0
& Z/ X" }5 e0 Q6 I4 D4 q ' Do not create zero length lines
6 z8 b T, s' Q- v If Math.Abs(stpt.x - endpt.x) > 0.000001 Or Math.Abs(stpt.y - endpt.y) > 0.000001 Then- F3 X, L! \5 z6 x/ }
curves.Add(sess.Parts.Work.Curves.CreateLine(stpt, endpt)): M$ A/ x! t& r: {
End If8 ^! M. y! z9 W7 H; _& s
End If3 x7 o+ J- }7 R+ X
Next& P+ A' b" D+ w+ V/ n5 _
If SelectThickness() Then
8 }! g! A4 G) R( c1 L4 o9 V9 d3 k CreateSketch(): n* q6 F( o2 C7 E4 t
CreateExtrusion()+ S) U% P+ k) n; b' Q7 X% G
End If
' `+ r6 y# V; y9 V* ~ End Sub. e. w3 g9 c: J) b3 A* Q" O
End Module
. r$ N ?) c% z0 V; n$ a: q6 j1 g2 I! h& L6 ~0 } }
+ o$ Z: u A% w9 L" y8 @" P! A
8 I! a8 F* r: b4 d% E
|
|