|
' ug刻字源码 +QQ 609719845/ z2 a& l6 B4 F n) F7 ^$ i8 E5 S
' into geometry using a true type font and
1 U( M* k2 Y* z5 N1 [9 A) c, U' extrude the result; j$ c1 j) D; J, J; \
9 @+ \( y- R) }( |
Option Strict On4 `6 ~) z5 f1 ^- I
& N- M& Y5 r# O9 B: |& s ?: ?8 SImports System
; R( s4 _5 t+ v2 D! fImports System.Drawing C# O+ b. X+ P5 ^ R
Imports System.Drawing.Drawing2D
2 X9 K- G+ A: n# s* g0 LImports System.Windows.Forms, r& U3 D2 R& d0 B1 e* H+ v
Imports System.Collections! `6 w6 Y. U e4 Q" _# n+ I
Imports NXOpen0 a$ D4 u. b2 [. ^8 P$ C+ O" U
Imports NXOpen.Features
! _4 ]5 Q3 Z* U. [7 F/ x, ], {Imports NXOpen.UF
* l! W q2 n. QImports NXOpen.Utilities
! z4 s" {$ Y+ {( @- a7 hImports NXOpenUI% J" m5 Q1 R0 [! j$ o
- @: _ P2 A7 `/ G# r# f/ ]Module DrawText* t! A7 I/ n5 _& F
0 p7 @; G' \2 Q8 U% S Private sess As Session6 v7 x/ m$ i. i6 }: X
Private ufSess As UFSession d9 e( g& j$ T+ V' r( L% L
Private origin(2) As Double
/ O" X1 L9 T% `2 K4 H/ W0 I& W+ }% ` Private path As GraphicsPath/ Z" y# K1 a2 F0 F9 j/ O
Private text As String
8 q" c2 R' I8 i- r# b q, ~' H Private font As font
9 P7 A7 y4 M# P6 H3 j Private curves As New ArrayList7 x# [5 f0 X8 d4 W& F" k
Private sketch1 As sketch
: C+ U; ]2 L2 I Private thickness As String
3 e& M9 B% [4 D5 _4 b9 g& \7 M Private undoMarkId As Session.UndoMarkId V* ^/ w% W: C! N* ?7 F# ^
, I. o9 j) [* h2 N# j$ i& b7 P
' Prompt the user to select a font.
/ m" l, P3 X4 n9 P ' Return True if successful
4 w6 {/ K! i& L7 V$ [( I# n0 a ' The Module level variable 'font' is set to the resulting font.) d1 A; j! p [% s
Function SelectFont() As Boolean
5 s! R; L$ j. g$ J2 T7 ` Dim fontDlg As FontDialog = New FontDialog
4 _3 ]" F2 ?# R, C2 h1 N" [4 i1 X6 d+ S( X/ [; L
SelectFont = False
% o) E% o# P7 s& W+ M* X If fontDlg.ShowDialog() = DialogResult.OK Then" M0 \' Q4 l/ D# z* w" w! }1 v3 K" C
font = fontDlg.Font
5 ]9 m9 E. ^) I& D; H2 l/ \ SelectFont = True7 q1 d) n9 Y7 A+ d6 p: U# m
End If
) p" q2 i. K& X, f) E4 p, h) w6 ^ End Function& S3 R' s6 n1 T7 z
' Prompt the user to select a screen position
0 I; w# W5 ~0 e) x' g ' Return True if successful' [/ s" w5 B3 z
' The Module level variable 'origin' is set to the resulting point.
' Y* c2 [7 F$ l* i6 o Function SelectPosition() As Boolean
2 C7 [. v& h# v$ G Dim view As Tag
' R# D/ E& ^7 k& l Dim response As Integer. C J ^. t) g
- |# W# Q% W( x3 ] ufSess.Ui.LockUGAccess(UFConstants.UF_UI_FROM_CUSTOM)
( S$ r4 T9 ]0 E. X% [. o0 v SelectPosition = False2 D% W4 e' R7 W, t. U4 Z$ H
Try: s, w% }* p- R6 G9 o+ k/ p5 K
ufSess.Ui.SpecifyScreenPosition("选择字体", Nothing, IntPtr.Zero, origin, view, response)
& }- V6 n5 H. A8 }- n If response = UFConstants.UF_UI_PICK_RESPONSE Then1 ]/ _6 _- ]% x& n
SelectPosition = True( s* A* U2 { C5 {4 Z2 s
End If
8 G# A7 I4 g# Q: G! V: Y& b" I Finally
, C( _) H D% d ' Restore UI state always including in case of error.$ T( X# E) E9 M2 X* T! j
ufSess.Ui.UnlockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)
* y0 z* d3 C* Z: A, V# I; p3 Y. f& m End Try
+ X* F) k) F! A+ [5 b3 E& y1 [ End Function
- u- @% d: I7 D' M) q }4 h& d- Z9 m. x+ U ' Prompt the user to input a text string to convert.' Y6 T5 d3 H, W6 `0 p' r+ T. N
' Return True if successful |+ ^9 Q" y7 O S4 S& |/ [
' The Module level variable 'text' is set to the resulting string.
+ g6 w$ o! k$ h: y6 h3 d$ r Function SelectText() As Boolean
- S) m6 a, q& F+ U; a text = NXInputBox.GetInputString("输入文字", "Enter String To Convert")
: y# [% T# q. f# |& [2 V% L SelectText = False/ {0 [5 W* w/ Q$ _+ i6 F
If text.Length <> 0 Then) X- w+ _5 ]# D3 x: `- {1 `
SelectText = True
4 H$ H( l! [- }3 `* u End If
0 n% q0 ^' w L! M End Function
" N! f1 M. Z, q9 P0 B ' Prompt the user to input an expresion text string to convert.
$ w. B ~6 y" h ' Return True if successful" j/ Q0 M1 N& w F
' The Module level variable 'thickness' is set to the resulting string.
1 Q$ Z L6 Z* P, \6 K' E Function SelectThickness() As Boolean) J- s' f" |3 |9 w; d) O; [
thickness = NXInputBox.GetInputString("输入高度", "输入高度")
1 b4 w" C6 I$ o$ Y, t' [7 z$ p SelectThickness = False, C" ?4 c3 A& u. s: e/ W7 m# N
If text.Length <> 0 Then
$ n, h; e$ T/ b0 X0 s SelectThickness = True
) k5 `9 C1 z. q0 O3 Y/ a3 s- i End If
+ G6 U' R/ v: x3 @- y End Function/ B5 S4 c* \5 a/ m/ ^; G0 n0 ^
' Given a subset of the graphics path between the given indices ! a4 S6 D) \9 C( a3 g7 a
' create lines between the points in the path.: `( u2 t: W# w5 ~' @' H
' Assumes that caller has selected an appropriate section of the path.2 ^. j' S* V7 r8 _
Sub CreateLinearPath(ByVal startIndex As Integer, ByVal endIndex As Integer)
9 u0 C" ^' e- R% k6 R Dim j As Integer
4 }' t& L5 @6 [" z" o2 a8 R For j = startIndex To endIndex - 1
Q. C) q3 n' l. b: c3 {8 P Dim stpt As New Point3d
( I! k; ]" I( a4 y4 N! c Dim endpt As New Point3d1 \+ l$ O; P) c D% G2 E+ }1 d. h: l
stpt.x = path.PathPoints(j).X + origin(0)
1 a$ ~3 U f! C7 q& t2 y- ^6 J stpt.y = -path.PathPoints(j).Y + origin(1)
$ U% z Y8 A9 e( b stpt.z = 08 ?4 w; `1 s; g$ p* `% Z2 l+ q2 J
endpt.x = path.PathPoints(j + 1).X + origin(0)
" o, x5 x9 q6 r% u/ n( @4 o- h# y8 b endpt.y = -path.PathPoints(j + 1).Y + origin(1)
# W; }- d! }& _: W& h1 H endpt.z = 0
4 W# C C6 }9 c, _* ? curves.Add(sess.Parts.Work.Curves.CreateLine(stpt, endpt))
( G" h7 M1 ^7 [8 l. c Next
" C8 l+ g/ P; c7 _- m End Sub
. O3 m$ N. [. G' c; H z ' Given a subset of the graphics path between the given indices ; w9 P3 P. ^6 O$ D3 i- `2 m
' create splines between the points in the path.
1 | X E. K, {/ A: X ' The path contains bezier segments and this converts then to B-splines. N ?' I( k+ z2 `3 T: L- ^
' Assumes that caller has selected an appropriate section of the path.# ?$ K+ a9 ~3 P! E0 A( x
Sub CreateSplinePath(ByVal startIndex As Integer, ByVal endIndex As Integer)
+ _& U. }* h4 p+ [ Dim j As Integer! x4 @8 G1 u* i3 O- \3 p' [; y# ^, P( ?
For j = startIndex To endIndex - 1 Step 31 M$ E0 t" m( ]# Y' v' h7 K" G' `
Dim poles(3, 3) As Double7 E4 X* p) i1 `6 p
Dim k As Integer
& Q- O$ B& l6 N# @ [ For k = 0 To 36 B' o, B2 w- R8 j& a
poles(k, 0) = path.PathPoints(j + k).X + origin(0)
, o; O6 |7 F4 F+ L: [* P8 m2 ~ poles(k, 1) = -path.PathPoints(j + k).Y + origin(1)( h& Q0 P; \8 R+ b$ E
poles(k, 2) = 0
, o, c/ y7 g0 m2 c/ l: {: R poles(k, 3) = 1' y4 X1 I3 p* U$ T5 ]0 p9 i
Next
4 w& n/ ]( j& ^ H$ O* A Dim knots() As Double = {0, 0, 0, 0, 1, 1, 1, 1}
9 f, J" s9 U* f; E* X8 s8 s4 A Dim spl As UFCurve.Spline4 Z, p, v* r: y
Dim spline As Tag
' Q$ q5 |; c5 k2 v2 Y Dim num_states As Integer: e* b7 _6 w- ~
Dim states() As UFCurve.State = Nothing
- ~. t# G9 b, K3 }. }7 L2 u spl.start_param = 0
4 ^: `8 ?3 x7 P6 f& S+ b spl.end_param = 1 r$ I+ I. H- L" x$ ^
spl.is_rational = 06 I g) o, W( S
spl.num_poles = 48 [+ V4 E: N. ~+ z
spl.order = 4
: K$ c! _$ ^) b+ s. h% r3 f spl.knots = knots3 I- O8 O) K- Q) \
spl.poles = poles
5 b- A. d1 }( Y9 O! u ufSess.Curve.CreateSpline(spl, spline, num_states, states), y" W8 r) n" W! _
curves.Add(NXObjectManager.Get(spline))
& \4 d' w ]5 ?9 O' d' \" j' B Next
9 W8 g/ W: D# D3 u9 J4 x End Sub
1 D) K- m8 Q5 J1 G# N" r4 i! s$ h ' Create a sketch and add all curves we've created to it." E9 B/ e7 i- R: g
' Most of this was created by recording create a sketch and editting the result.* F% y4 w: t1 U9 d/ V
' Retries with different sketch names to avoid duplicate names.: f' r& R" ~: R6 V3 y
Sub CreateSketch(): O& p" H* X$ _, k( E ]/ l5 D
Dim theSession As Session = Session.GetSession()
R& M/ m# Q0 u. Z6 O5 | Dim workPart As Part = theSession.Parts.Work! [3 U2 O" z7 i/ _0 g. D
Dim displayPart As Part = theSession.Parts.Display% i) _, ^5 X" _- o" y+ a5 y
: n3 m' `& Q, }* n1 ?, Z
Dim markId1 As Session.UndoMarkId, z: u2 O$ K! D: u1 `
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")$ r% z$ j! q) R1 J; n: n' u
9 n- d. h( a, }% ~; ? Dim nullSketch As Sketch = Nothing+ v2 g6 D3 n4 W0 } |% y
& F& ]( B( j. L j4 ]' D1 G
Dim sketchInPlaceBuilder1 As SketchInPlaceBuilder9 s9 D! O) x$ v) M, y
sketchInPlaceBuilder1 = workPart.Sketches.CreateSketchInPlaceBuilder2(nullSketch)
1 {" |$ ]9 F# S6 C! Q; [/ u' N- @" W$ ~ S1 x& e* g
Dim unit1 As Unit = CType(workPart.UnitCollection.FindObject("Inch"), Unit)
" u7 P! Y( D6 U6 }7 P
r1 m z( r4 R3 J2 m" c* z2 n; [ Dim expression1 As Expression) s# [, ?4 p! z7 v# Q
expression1 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
( O7 ]' \% Z. n- V3 n' L4 c, e7 [% W+ a
Dim expression2 As Expression/ W1 b9 F5 I3 ^2 q1 R! [
expression2 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)4 D+ o+ t' Y% d, u9 L' `; k/ ~7 _
" j! m: w4 T7 B theSession.SetUndoMarkName(markId1, "'Create Sketch Dialog")( @. T4 @# u" K; m( ` M
( g/ c- X7 R/ [
Dim markId2 As Session.UndoMarkId
3 r2 b# Z2 v+ p# a markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Create Sketch")
. [+ n: u/ H) X* p; ]# f" o: Y
5 f2 G$ s8 q5 H% u. C# j- {; l9 M theSession.DeleteUndoMark(markId2, Nothing)
. s9 G6 |1 S- c! ~& ]- E# i9 {5 E$ ]3 W( @! X! \
Dim markId3 As Session.UndoMarkId
( X$ T8 S* ^' o# ^ J markId3 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Create Sketch"); |$ C1 ~( G+ U# r4 V& X$ R
0 E; Y" m3 q' F9 f A ' Inferring constraints and auto dimensions may take long time and is not really required for drawing text. ! P0 p7 C8 r$ |: V' Y
theSession.Preferences.Sketch.CreateInferredConstraints = False
* n" T4 A1 s5 P% f1 T/ J theSession.Preferences.Sketch.ContinuousAutoDimensioning = False( b6 y; i. m7 ?1 f+ Z3 h6 ~
theSession.Preferences.Sketch.DimensionLabel = Preferences.SketchPreferences.DimensionLabelType.Expression
+ T' S1 ~* R& p4 S1 C4 ] theSession.Preferences.Sketch.TextSizeFixed = True2 [. P. D( s, z4 J) h
theSession.Preferences.Sketch.FixedTextSize = 0.12% T( o! m- o. N9 u: T/ _) T
theSession.Preferences.Sketch.ConstraintSymbolSize = 3.0# ?; X7 r$ Y: K+ Q% U% f9 c
theSession.Preferences.Sketch.DisplayObjectColor = False
4 Z4 c: s5 m1 M; B* _ theSession.Preferences.Sketch.DisplayObjectName = False
5 c/ v4 ]' B3 q5 t% {- k% G6 k, {, z/ n5 H t( s6 P7 V
Dim nXObject1 As NXObject
. Q* R3 @& Y0 W" d nXObject1 = sketchInPlaceBuilder1.Commit(). _) n" L0 ^- _+ I* u6 k& p
sketch1 = CType(nXObject1, Sketch)6 j5 q# R" p g4 P3 j# O
$ I9 h1 V3 {& l% \& ]) b# r Dim markId4 As Session.UndoMarkId( S4 r' _3 b. u
markId4 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "update")
. T; v; K; }% j0 q. w2 D6 V9 G7 K, a: B) k# M
Dim nErrs1 As Integer
) P$ O* H8 k+ d- z4 | nErrs1 = theSession.UpdateManager.DoUpdate(markId4)
4 h! d# T Y* f. M0 [' x: Q: J
0 z. H6 I0 f# Z7 A+ n$ |) ~, D sketch1.Activate(sketch.ViewReorient.False)4 ?# h0 H* B& v
6 L6 a# \6 q8 o( i3 t1 r& x+ `; O
Dim curve As DisplayableObject
f+ K$ A% Q+ J$ \$ ? For Each curve In curves2 l% X' D: k' L. m
Try8 P I. a' O" z9 p" f3 D
sess.ActiveSketch.AddGeometry(curve)( J) E+ \$ U* A" x4 Q
Catch ex As Exception9 Z9 L% ~: ?5 U
MessageBox.Show("Could not add: " + curve.ToString + " to sketch " + ex.Message)) d. E" C0 J# [% F# n+ v
End Try
% s5 k$ r6 Z* H( X9 X7 P$ S5 C. I Next
4 ^. | H7 W% e
2 z& l$ D+ ~* G* ~ sess.ActiveSketch.Deactivate(sketch.ViewReorient.False, sketch.UpdateLevel.Model)
: W7 k. k' O& p, {0 Z& r$ c: W h
2 ` s# U6 X2 ~* T theSession.DeleteUndoMark(markId3, Nothing)& o0 s7 Z6 x' j, r
theSession.SetUndoMarkName(markId1, "Create Sketch")
! q: z& Y9 a! K, P G/ C# g sketchInPlaceBuilder1.Destroy()
, G, s* g# w" w
2 ~0 y! w5 E+ L' t' P" k/ h Try- d1 Z% c2 C: v. C
' 'Expression is still in use.' w: v* t5 ~' z: j
workPart.Expressions.Delete(expression2)
% N' f' ?3 j+ C. _6 i% Z Catch ex As NXException3 \- w* A/ L# t8 S8 u$ `4 x* l
ex.AssertErrorCode(1050029)
$ K+ \* y4 Q. R End Try4 C$ M" D) Z9 S+ e
) Y5 N4 M- N; E( r: T2 J Try: ^! H/ K. p9 i: D2 G
' 'Expression is still in use., I) S5 h, J3 R' P8 h0 t
workPart.Expressions.Delete(expression1)* q+ ~6 F0 u1 z# E; P/ `
Catch ex As NXException |- U h- [3 w' r2 I" s1 _
ex.AssertErrorCode(1050029)
3 F' }% h% h7 j% b End Try
+ N" U# n2 C. t" e3 W: i
# I# M$ w/ d7 P4 S! R5 n& t# f End Sub, g3 G3 A, ?$ q+ V2 W4 A, y9 B: W/ x
' Extrude the sketch2 |" s% Q/ ]$ p+ F0 S; X* T
Sub CreateExtrusion()
: m0 }0 _/ m: P7 o& _5 N5 L( l8 `( U
* ~) s8 D$ A4 t8 Y Dim nullFeature As Feature = Nothing
+ W3 S6 \& x# S; t1 k8 O$ C
1 l! V3 C$ g% m# g5 \ Dim extrudeBuilder1 As Features.ExtrudeBuilder. H; p8 U9 Q1 X( r
extrudeBuilder1 = sess.Parts.Work.Features.CreateExtrudeBuilder(nullFeature) x7 z. K% g4 X6 g; W
/ |4 \* Q6 `% \7 g7 x9 e8 q
Dim section1 As Section( K3 w% [2 s- Y2 u4 ^
section1 = sess.Parts.Work.Sections.CreateSection(0.000001, 0.001, 0.5)
7 ?; j) U& j+ c1 P6 S" v
1 m& c3 D+ M+ ~( i& V) }, w Dim featureArray1(0) As Feature4 `7 u) B' q ^. `
featureArray1(0) = sketch1.Feature1 A: m9 _4 d0 ^) V' p3 O
Dim curveFeatureRule1 As CurveFeatureRule
# u: _2 p H* @ curveFeatureRule1 = sess.Parts.Work.ScRuleFactory.CreateRuleCurveFeature(featureArray1)
9 k! B$ ]- A- i: m, ^1 b# }8 I# j& [' R$ [
Dim rules(0) As SelectionIntentRule
, K9 U0 }# {, A rules(0) = curveFeatureRule1
5 i9 A2 H3 ]4 a2 \ Dim geoms() As NXObject = sketch1.GetAllGeometry()
( ?' Q4 B" T# P; |0 \ Dim helpPoint As Point3d = New Point3d(0, 0, 0)8 i" K; r' x9 J
section1.AddToSection(rules, geoms(0), Nothing, Nothing, helpPoint, Section.Mode.Create)2 i8 x) t3 s$ ?: g+ b& g3 j
* C a' I1 R* ^0 Y' i4 l
extrudeBuilder1.Section = section1
" E( W% n2 R8 |4 T" R0 K
8 U- {; l; e: Y Dim direction1 As NXOpen.Direction$ a0 d# k" N9 S) h
direction1 = sess.Parts.Work.Directions.CreateDirection(sketch1, Sense.Forward, SmartObject.UpdateOption.WithinModeling)( f, }8 Y' k( C) `2 k! y# W
extrudeBuilder1.Direction = direction1% O6 y8 J( Y" x" |9 [' G* c8 g
3 D6 Y# ?/ E6 b( ^: l8 [! F extrudeBuilder1.Limits.StartExtend.Value.RightHandSide = "0"! |$ e. f0 z8 O5 G
extrudeBuilder1.Limits.EndExtend.Value.RightHandSide = thickness
/ I* J/ `. H+ R( Y- V' K r! l# I9 [# ~) P0 C% r+ x5 v- \4 B! J
Dim featureOptions1 As GeometricUtilities.FeatureOptions+ g; I! ^! B/ S& k0 A" `6 S' q" o
featureOptions1 = extrudeBuilder1.FeatureOptions
/ `; K8 {: K, f' g6 t( h6 b$ |# J featureOptions1.BodyType = GeometricUtilities.FeatureOptions.BodyStyle.Solid
% a( ~- r7 z4 I4 P$ [2 V) u0 q2 ]7 S
Dim feature5 As Feature1 w; d4 j/ c( b2 ]# r6 b* C
feature5 = extrudeBuilder1.CommitFeature()
* Z! d/ g7 j! H- O; ?3 c7 t
" H$ p* S) j- X T) h0 v8 E0 h extrudeBuilder1.Destroy()
$ B- Z4 I' C( k9 B
0 h) v: C/ t0 A% j7 D+ U: g5 e End Sub
& E/ E3 T2 j/ [) y0 p% _ ' Main routine for this journal$ O6 S5 q* e; A* G; U% Y
Sub Main()- S; G. _4 l6 ^& R5 @7 o) W
sess = Session.GetSession()
1 M0 I+ V5 y8 B! Y ?6 R" J5 T ufSess = UFSession.GetUFSession()
( N2 n( p4 l. _+ h4 B- K9 v( w6 P& w. S
If Not SelectFont() Then
1 d) D; [8 {/ T$ v7 b3 Y) G Return4 v9 ]7 y& I9 ?& x( }+ `* T
End If: u: ], I& \2 W& [
If Not SelectText() Then
4 u4 j9 v1 }6 y) f- c Return- a0 ~2 g1 ]0 G* Q2 F0 \
End If: {" c2 z& n. q
If Not SelectPosition() Then
* P Q X" o( a3 R+ f; [7 y Return! {& z+ n! Z% w# i5 s/ ?% `9 o
End If9 n: b6 P8 @5 p0 O8 r
) P7 }) r8 P; ~; O6 j3 F% D2 s undoMarkId = sess.SetUndoMark(Session.MarkVisibility.Visible, "Create geometry from text")
: j# n3 q, ^: Z. T' K/ i1 P8 g* {" o. p
path = New GraphicsPath(FillMode.Alternate)) _; t, K1 N' d( }
Dim zero As New System.Drawing.Point(0, 0)
+ _ W- q$ T+ g1 a4 D, _7 k Dim format As StringFormat = StringFormat.GenericDefault1 G9 J$ `1 o) Z' s" W1 K9 T0 D
path.AddString(text, font.FontFamily, font.Style, font.SizeInPoints, zero, format)
; L" n+ @' [( ^( q) W2 R( ^5 _9 O; A& l, c* i
Dim bounds As RectangleF = path.GetBounds()
0 k. b. ? e6 w2 q" Z Dim gpi As New GraphicsPathIterator(path)! E0 `4 b5 G9 e- \% N8 U+ ]- C
gpi.Rewind()$ n2 X2 h1 _* k4 G% V
. S- u" W* T, I( A* e0 n origin(0) -= bounds.Left
4 B. B+ H: i* Z2 f' J' `5 z- U origin(1) += bounds.Bottom
2 u. @4 r3 X8 w% E: T, C/ a/ b0 u# k+ O( B
Dim iSubPath As Integer
6 e$ G, O a: \: p8 W0 n7 m Dim subPathCount As Integer = gpi.SubpathCount
! s- z+ ~+ C* W; f1 a
& y8 z$ _1 A; I0 y For iSubPath = 0 To subPathCount - 1# X9 l# s' J; t& ?
Dim mySubPaths As Integer. L2 U/ _& x! K0 l/ F
Dim IsClosed As Boolean+ E5 Q' }+ m' M# Q) X( I" y0 p
Dim subPathStartIndex, subPathEndIndex As Integer; `# V) m9 v" K9 B4 C# V @
Dim stpt As New Point3d) x0 o" I; L2 V
Dim endpt As New Point3d3 a7 G0 |7 k" q
0 |5 }+ [- @* X6 v: a1 `; F
mySubPaths = gpi.NextSubpath(subPathStartIndex, subPathEndIndex, IsClosed)
' a6 G* g$ |4 C Dim pointTypeStartIndex, pointTypeEndIndex As Integer0 x" a. q/ c4 h. ?' l R$ e/ G
Do
, _: J2 H& E: L5 _- o Dim subPathPointType As Byte$ d8 M) f& i+ `3 _* n$ s
Dim numPointsFound As Integer = gpi.NextPathType(subPathPointType, pointTypeStartIndex, pointTypeEndIndex), |: ~ H' S# n' t2 m4 J6 u. R
Dim type As PathPointType = CType(subPathPointType, PathPointType)4 N+ Q; f3 R( y4 _8 b3 @
@& Q! s( I/ u* n% q" q If type = PathPointType.Line Then
0 s: q$ C) |, d W: b' ^7 A CreateLinearPath(pointTypeStartIndex, pointTypeEndIndex)
2 G, v; n2 v2 N7 T# g6 n' u V# Y ElseIf type = PathPointType.Bezier3 Then+ M+ B/ M$ c* Z4 m: P
CreateSplinePath(pointTypeStartIndex, pointTypeEndIndex)9 K+ }. ?( |7 L5 K9 K
End If
! x7 G/ A' s2 ]2 z Loop While subPathEndIndex <> pointTypeEndIndex0 p6 k* f* W- k9 V4 G
If IsClosed Then( H, ^8 m0 `/ r& l3 h7 |6 k$ c
stpt.x = path.PathPoints(subPathStartIndex).X + origin(0)
$ V4 ]1 _* n4 {* `4 V( }, [3 |7 ~ stpt.y = -path.PathPoints(subPathStartIndex).Y + origin(1)0 i$ P5 W" V) `" U/ P) a, Y' u" B* Q/ J
stpt.z = 00 s: @. ^5 H8 j9 o: `* J( }
endpt.x = path.PathPoints(subPathEndIndex).X + origin(0)
; H- f! d3 B% m7 M endpt.y = -path.PathPoints(subPathEndIndex).Y + origin(1)
; E; g4 Q& a+ P- e endpt.z = 0
! Q8 ?+ X7 d5 C- E ' Do not create zero length lines6 }7 Z2 h& p4 p4 t/ k
If Math.Abs(stpt.x - endpt.x) > 0.000001 Or Math.Abs(stpt.y - endpt.y) > 0.000001 Then) n/ x; l7 j( ]# j: h3 A% J
curves.Add(sess.Parts.Work.Curves.CreateLine(stpt, endpt))' M' K+ g* m- p4 Q6 N' P% P) U; Z/ U1 Y
End If8 W3 C0 ] V0 g/ m' n/ d
End If
$ s; h0 J7 @. p$ p0 j( r Next5 {- m! M" s) o' E* C2 r
If SelectThickness() Then0 y% K, l) h1 G7 W! P/ C
CreateSketch()
" n3 y U2 `9 L: z1 k) Y% t CreateExtrusion()" i4 {* p; \8 |( Y
End If
( I. I6 j6 e2 q8 X; a3 | End Sub1 r% q1 m }8 k% e+ L6 k8 D7 }0 z' ^
End Module+ Q8 R9 P' I6 F% z c0 x) Y+ ?
8 s; p/ O c( G( i# }
( [, M4 e' x9 j+ w/ K a. y
# _$ d- m- G5 K. {6 I |
|