|
' ug刻字源码 +QQ 609719845: e8 @3 R) u( u2 g) {( K% k, o% W/ y2 M
' into geometry using a true type font and$ z* f3 w# s. e6 E
' extrude the result
! }1 x0 j0 e% M# [ e0 H$ L# {, W$ n
, {: F* j3 D3 |* @7 qOption Strict On
; z6 E) s v& _2 T5 u% t/ a& r2 g
Imports System! S# F0 V' Q% n2 Z; P
Imports System.Drawing8 |/ u8 P3 C$ F6 Y, g2 S; R: U
Imports System.Drawing.Drawing2D
! h2 m6 p' {9 y1 C0 Z& }! k: yImports System.Windows.Forms
9 F8 v8 j! d: w# K+ B v# H3 \7 |6 pImports System.Collections& N W( n; p$ F
Imports NXOpen
; }% [2 ^$ q3 g0 e! |Imports NXOpen.Features, k$ i1 V# G& I d0 V6 X d
Imports NXOpen.UF
d7 v! \" O/ \# ~+ w' zImports NXOpen.Utilities
" ^5 c) O+ C, W+ b5 WImports NXOpenUI& l& v; t- y8 b; \7 N
8 w8 A" f* M$ d, N' m) o
Module DrawText7 K7 [" ~- Y h
9 n: b( i* @" x- p
Private sess As Session
+ W5 q4 V$ U4 Y7 A S4 v Private ufSess As UFSession$ J. U$ E+ s8 W m6 @
Private origin(2) As Double0 Q3 L! _7 b. d' [
Private path As GraphicsPath9 E ?) G' b8 X
Private text As String
5 m$ y6 v0 K3 u! L Private font As font
. f& Z8 u4 w; f+ f& p& V% J# P G! ~ Private curves As New ArrayList; ^% S& a4 l1 X$ A7 r' \9 V3 f
Private sketch1 As sketch
: c" e8 |5 n% {7 j( ~; ^ Private thickness As String
6 G, `, d3 B+ ]! X9 I% ^ Private undoMarkId As Session.UndoMarkId
/ T6 u' g4 Z3 o$ r
/ [! O6 U* u$ ?9 q: R ' Prompt the user to select a font.$ K/ `4 @( w( n1 U2 a
' Return True if successful
* l/ o% @( m' D3 N Q ' The Module level variable 'font' is set to the resulting font.8 V; U a- n4 L! e8 d, ~
Function SelectFont() As Boolean- J" u4 d5 K/ U: y; |( g+ [* V
Dim fontDlg As FontDialog = New FontDialog
5 t/ G# _7 a2 {6 ^1 j9 ?! a3 g( l" w( |/ l1 e) R' V& v. r, ~/ M0 w
SelectFont = False
- I/ e! r9 _0 l3 t0 b If fontDlg.ShowDialog() = DialogResult.OK Then( |. D' H% Y. R1 @( x0 @
font = fontDlg.Font
( a0 J1 w/ Y- F SelectFont = True* T2 o: s. m2 E6 J$ v" H. m& `; j
End If, K6 J% n5 |' l: t C5 j, N; ^
End Function
+ l& D Z! |; t3 _' c& b ' Prompt the user to select a screen position( o' q9 R4 u6 t# e9 @% e2 T( X
' Return True if successful
$ D7 a4 a2 z" _' p2 _2 Z# d3 p/ H ' The Module level variable 'origin' is set to the resulting point.7 w3 T! C6 {8 y7 K
Function SelectPosition() As Boolean
- C, k v& R( Q! K' S* B6 R Dim view As Tag9 {4 a& K" O2 Q( M. s
Dim response As Integer
! \5 c6 v0 q, `( M& F1 U8 i
' P2 e" r: U2 ~5 ?$ B) y/ k ufSess.Ui.LockUGAccess(UFConstants.UF_UI_FROM_CUSTOM)
2 B- o: ^+ c6 Y4 u+ @: h SelectPosition = False
3 E: T& z- Y+ v" ` Try" L' r" l6 r' X/ m& v) O# w5 `
ufSess.Ui.SpecifyScreenPosition("选择字体", Nothing, IntPtr.Zero, origin, view, response)& H8 F# t4 V6 X+ L5 T* i
If response = UFConstants.UF_UI_PICK_RESPONSE Then" }/ \7 r6 B# H* l$ i. R
SelectPosition = True, |5 |2 F6 e- T4 e6 N1 h
End If
: f& }8 c; m- b; T Finally
3 c6 z" T1 m9 M ' Restore UI state always including in case of error.6 ?7 c$ }% D! _& c5 ` g8 n
ufSess.Ui.UnlockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)
y. a( S+ D! F' @( C( s5 L End Try1 I! K+ y% P, v# y9 s; j& t
End Function7 e9 l4 |7 u6 {9 B
' Prompt the user to input a text string to convert.
6 }0 b: z: S5 q9 y ' Return True if successful* `. _9 ]/ b0 O1 R9 m$ s2 v
' The Module level variable 'text' is set to the resulting string.
: U; B' y6 ]7 y# q( n( N$ b" r5 z Function SelectText() As Boolean
. Z4 r, R& @0 b. ?7 |# j6 Z text = NXInputBox.GetInputString("输入文字", "Enter String To Convert")
C5 G% J/ k; m+ @+ v SelectText = False
4 [4 r' ]: Z# Q$ u% t! p If text.Length <> 0 Then
" `' O, x$ S$ H9 k; a, D0 Z$ g SelectText = True: Y* r0 {& t8 A: W$ }. k
End If: \4 o4 R4 \" _6 J/ i
End Function
" {8 w6 s, M2 g& w ' Prompt the user to input an expresion text string to convert.
. f) _# L: T4 ] ' Return True if successful1 U! d+ j+ n, G. O
' The Module level variable 'thickness' is set to the resulting string.
% n, W& F- `$ ]4 u S, I Function SelectThickness() As Boolean8 O4 Q3 q( }( j2 b
thickness = NXInputBox.GetInputString("输入高度", "输入高度")
4 X2 j* V; g+ D" a4 n" a- Q SelectThickness = False* a9 Y/ _2 }$ b! K, _
If text.Length <> 0 Then
0 t" U1 \+ J! t8 W( v SelectThickness = True3 w8 @$ C; p$ P H/ \
End If
, T; `' k I( D' d End Function
0 G8 ?$ N, F+ f: y ' Given a subset of the graphics path between the given indices % m" m+ a0 c0 J4 C1 g3 o0 Y! b) [
' create lines between the points in the path.
8 N+ b. V1 g3 A ' Assumes that caller has selected an appropriate section of the path." k' X2 Y9 A+ ?; e) r9 {
Sub CreateLinearPath(ByVal startIndex As Integer, ByVal endIndex As Integer)
. o. \2 k8 x/ ~: m" f Dim j As Integer G8 O( Z2 t2 S x! `0 L; Q
For j = startIndex To endIndex - 1) x' e+ r/ m/ f; C% a. Z
Dim stpt As New Point3d
. J: _ Z) a( o+ U' I. A% J; F3 | Dim endpt As New Point3d
" ~$ u3 L6 v' b+ Q* y$ x# {3 T stpt.x = path.PathPoints(j).X + origin(0)$ a" D' [8 H; N- _ w. I
stpt.y = -path.PathPoints(j).Y + origin(1)' `9 h, I$ Y/ h1 ^& O% b5 D
stpt.z = 0
3 ]1 `3 r* L8 @! }$ A; [8 D( o endpt.x = path.PathPoints(j + 1).X + origin(0) z: n I, d- F4 P8 J* J
endpt.y = -path.PathPoints(j + 1).Y + origin(1)( t- n# U% V. h" b" @; D- g
endpt.z = 05 ]# k& E# ]! P2 E' [+ f( U
curves.Add(sess.Parts.Work.Curves.CreateLine(stpt, endpt))
, }; Y& O4 D# X! G/ i! c. m Next
& s7 y* r, Z5 p$ B- s End Sub
6 Y- S; }2 I- Q* L ' Given a subset of the graphics path between the given indices
/ Q5 J2 S/ d3 i$ D9 J+ i- O ' create splines between the points in the path." _4 s6 ?: T7 T
' The path contains bezier segments and this converts then to B-splines.1 k. u3 ]3 {: J6 b, `- o# s- M, g" l
' Assumes that caller has selected an appropriate section of the path.
, S4 R1 H1 z4 Z i" M Sub CreateSplinePath(ByVal startIndex As Integer, ByVal endIndex As Integer)+ c2 x0 L. p: t4 V! h6 J
Dim j As Integer
9 J6 N* G. K6 f1 q! o# h. B; K For j = startIndex To endIndex - 1 Step 3
, {2 g$ Q1 ?( T( i- V Dim poles(3, 3) As Double0 F% Z0 h! F7 q- `& W) c. Z) j+ v
Dim k As Integer0 @8 n' l3 k* ?5 D5 ~
For k = 0 To 3
! k2 G; \' F' s% y4 p poles(k, 0) = path.PathPoints(j + k).X + origin(0)" |- y. e: L, B+ v- E
poles(k, 1) = -path.PathPoints(j + k).Y + origin(1)$ c0 x( w/ N& u5 Q( q
poles(k, 2) = 0
# {- K( l( b5 _9 }! W' T$ D poles(k, 3) = 1( {% z9 R0 f" J- L
Next
5 ]$ B7 j4 x) O* P$ Z$ w Dim knots() As Double = {0, 0, 0, 0, 1, 1, 1, 1}5 `" X1 C( I' ^/ ^' T+ `
Dim spl As UFCurve.Spline' J; u( N; P( J6 t/ ~7 I& G
Dim spline As Tag& |2 y7 g* z9 r: Z f0 G
Dim num_states As Integer
8 R. G9 J6 f$ K) y F Dim states() As UFCurve.State = Nothing, d6 ]5 E. U( f
spl.start_param = 0
. M8 M* {6 s7 }* T$ ] spl.end_param = 1
/ s0 q1 c$ Q0 X3 G spl.is_rational = 0
4 c D4 E* W' e0 f/ b7 } spl.num_poles = 4- M! @% ]2 E4 h8 _
spl.order = 4$ i- [3 C" K4 c; J
spl.knots = knots
7 f2 @( B+ v3 g$ b spl.poles = poles
8 u- W' z) v, N( u7 \) n ufSess.Curve.CreateSpline(spl, spline, num_states, states)
3 u# Z( h* b R4 v; }' q) ^ curves.Add(NXObjectManager.Get(spline))" y5 U6 H3 }( H4 c
Next
7 I {- e( Y& X, U# z( a End Sub
1 }# j2 O" v0 ^6 j; u4 E8 T ' Create a sketch and add all curves we've created to it.
# p6 |9 a3 r- V }3 j# m6 o ' Most of this was created by recording create a sketch and editting the result.4 r4 ?/ ]4 Z0 T. Y/ g& V
' Retries with different sketch names to avoid duplicate names.% `: Y, w& f% ~. w3 S) @
Sub CreateSketch()
1 b7 F, W1 T k/ d8 A Dim theSession As Session = Session.GetSession()
" ^; j# q8 m9 B$ W Dim workPart As Part = theSession.Parts.Work
7 e" o# g5 [: n! P X Dim displayPart As Part = theSession.Parts.Display; x- k5 g% V w, M2 b
2 \8 Z. O% A3 h" a6 B( W
Dim markId1 As Session.UndoMarkId; v) P @6 Y2 g" {2 H" \
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")
" f9 x, w' ~- Q N/ I: o. N
& S4 X, i+ t% F* P( [% Z Dim nullSketch As Sketch = Nothing
1 I+ U; p$ S2 U j1 K% }
1 q2 U8 y7 x5 x1 b# W( H Dim sketchInPlaceBuilder1 As SketchInPlaceBuilder
7 G1 v0 A; F7 ? sketchInPlaceBuilder1 = workPart.Sketches.CreateSketchInPlaceBuilder2(nullSketch)1 ]# ?8 G M# }8 S
0 D; L: i' t0 D W8 j Dim unit1 As Unit = CType(workPart.UnitCollection.FindObject("Inch"), Unit); @8 Q/ K. W; q% w
( m3 U6 Z( |4 s+ I- k! L Dim expression1 As Expression
1 T. A' a& Z/ |3 V. ~( p' m8 M" Q expression1 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
: ~9 e7 d$ i I9 f8 `( I
; T# T$ ?& W1 D3 z0 _ Dim expression2 As Expression/ d8 h" X' x L( d
expression2 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1): a, R' ]( S. E- Q9 ~& A
4 F4 ]5 A4 N, }) e$ `: \ theSession.SetUndoMarkName(markId1, "'Create Sketch Dialog")
$ F9 z4 Z+ E4 e' S4 W9 C, q6 {& r k
- ~7 M( L" V- j: J6 B* u7 d Dim markId2 As Session.UndoMarkId
! }" ?) R! O; B markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Create Sketch")$ o0 J/ G) E. B% Z
5 p9 C7 M, D: \$ J. a9 Z- b theSession.DeleteUndoMark(markId2, Nothing)
9 t" B; _7 F% x5 M" ~# G6 U
0 x+ A) S* [1 }$ O' j0 o4 |0 z Dim markId3 As Session.UndoMarkId
8 M+ x7 s. E& C8 J markId3 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Create Sketch")
! U$ c7 {" _% }
2 d3 v2 q2 A |; s" O ' Inferring constraints and auto dimensions may take long time and is not really required for drawing text. % Z/ O% R. R3 Z+ `: P6 ?/ P0 m
theSession.Preferences.Sketch.CreateInferredConstraints = False
# o6 z+ K6 v$ @' l$ x theSession.Preferences.Sketch.ContinuousAutoDimensioning = False: T% [1 J3 H: M1 {0 l& o# }. y
theSession.Preferences.Sketch.DimensionLabel = Preferences.SketchPreferences.DimensionLabelType.Expression
- a' ?$ e* r% q1 L. @7 d9 P* E theSession.Preferences.Sketch.TextSizeFixed = True
8 Z% S: {7 d/ I3 U) } theSession.Preferences.Sketch.FixedTextSize = 0.12
( [: b* R8 {1 M" K7 y theSession.Preferences.Sketch.ConstraintSymbolSize = 3.02 d( R1 I: z0 }% o2 ~. Z- _
theSession.Preferences.Sketch.DisplayObjectColor = False- L/ f- l4 e# e+ t
theSession.Preferences.Sketch.DisplayObjectName = False7 Q' H: {( @6 z7 O7 l7 G" t
8 [0 [% I, S5 Y/ {7 \! z
Dim nXObject1 As NXObject: O5 Q: K( {. k. G* f- A* \( ~
nXObject1 = sketchInPlaceBuilder1.Commit()# f; s. r! o- _! m9 o$ \
sketch1 = CType(nXObject1, Sketch)+ B9 } d7 @0 Q |* L
P" D( V; n% w! ?1 x/ @
Dim markId4 As Session.UndoMarkId( Q0 B# g5 p" G8 o6 }$ s, G- V4 Y4 _
markId4 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "update")
* d+ X* O/ K, k7 q9 X( G( v6 I1 s# I9 V& c0 k$ Y8 D y; K
Dim nErrs1 As Integer% s$ O) S- U# U
nErrs1 = theSession.UpdateManager.DoUpdate(markId4)- A9 S. h! ?$ @* h
1 [2 ~7 z, u; X
sketch1.Activate(sketch.ViewReorient.False)
# [* C) g0 f F: J8 t0 ?+ k/ g
+ L! k- P) E7 o1 s' l Dim curve As DisplayableObject/ H) a1 e, v Z) A
For Each curve In curves
0 ~+ W' W" d0 E; a1 | Try
4 i& b- X$ Y% l# w1 L sess.ActiveSketch.AddGeometry(curve)
1 \) U4 M3 h( q/ H Catch ex As Exception
' Z! V$ ^2 H1 F0 n) E MessageBox.Show("Could not add: " + curve.ToString + " to sketch " + ex.Message)0 q" A6 E& G9 R
End Try$ I0 c; b; g6 E. F
Next
( R3 Y& @" ~; V/ Z" z+ b2 _& z1 q- {9 B* ]- Y6 N6 S
sess.ActiveSketch.Deactivate(sketch.ViewReorient.False, sketch.UpdateLevel.Model): P- P1 B6 R& R Q- J% i4 `
* @% t1 \# n2 o. c0 T
theSession.DeleteUndoMark(markId3, Nothing)
/ Q" J ]# n+ g1 f7 v theSession.SetUndoMarkName(markId1, "Create Sketch")" i9 `2 b' Z6 x5 Q/ t
sketchInPlaceBuilder1.Destroy()
. f' R/ x6 K: d: s
. t# D* U& r( o( j( B* Z$ T8 N Try/ N) z/ Q9 ~% i
' 'Expression is still in use.( I( T$ @5 `' C; l0 ?
workPart.Expressions.Delete(expression2)
- O3 x+ L4 `+ { Catch ex As NXException
5 Z8 s. V; r. z ex.AssertErrorCode(1050029)9 O4 f# D+ r( v% ?+ M3 N% \$ |: U
End Try
1 G5 i2 b2 R5 t+ ^ X( p
7 V1 {# |. B% q, H Try: G0 q2 i# `9 ~6 c' }5 A
' 'Expression is still in use.) B+ Q6 p7 d* y+ A
workPart.Expressions.Delete(expression1)# e1 Q, S' J' s c
Catch ex As NXException
/ M Y. {! f; l. _) Z9 u& ] ex.AssertErrorCode(1050029)8 G; k) `9 V% O, a) G! t3 w- |/ X! M9 U9 b
End Try
3 [8 t v5 x' z) j, h1 j6 q: p! @+ \2 V: ?
End Sub L( r, h5 O) f% G' Q! b
' Extrude the sketch( J6 x2 b; t7 u
Sub CreateExtrusion()7 Q. |0 o5 L# W8 o z/ L
2 `" R' l( F0 z( | {4 i% r6 n, c
Dim nullFeature As Feature = Nothing
1 S& I) Y' S0 X# ~( h" I7 {6 O& Z
b8 ?1 ]& O! n2 P, K& ^ Dim extrudeBuilder1 As Features.ExtrudeBuilder9 x- h8 x! o5 w2 d
extrudeBuilder1 = sess.Parts.Work.Features.CreateExtrudeBuilder(nullFeature)
8 h3 S9 Z1 M0 O1 b% H8 r
) l( m4 Q- R, K6 i) Q Dim section1 As Section& z5 u# H3 N- M( p7 m, N; C
section1 = sess.Parts.Work.Sections.CreateSection(0.000001, 0.001, 0.5)
/ \* s. c& K( B P- N7 e2 N3 {$ T u) I
Dim featureArray1(0) As Feature. _$ q+ v% Z& n
featureArray1(0) = sketch1.Feature
" c F* Q9 V H8 }8 ^! I Dim curveFeatureRule1 As CurveFeatureRule
: ~" s1 v- Z+ f) y# j1 w2 M: R5 J! z curveFeatureRule1 = sess.Parts.Work.ScRuleFactory.CreateRuleCurveFeature(featureArray1)/ p6 h$ S4 j; Z+ e
$ d6 J& J9 [7 D Dim rules(0) As SelectionIntentRule* A' Y2 T& W a% Z/ S
rules(0) = curveFeatureRule1; l9 }" C1 p& Z( }9 S; g8 a1 V
Dim geoms() As NXObject = sketch1.GetAllGeometry()& j# k# I' V, [8 e
Dim helpPoint As Point3d = New Point3d(0, 0, 0)
& c5 c( H0 R! R' `, ?1 B section1.AddToSection(rules, geoms(0), Nothing, Nothing, helpPoint, Section.Mode.Create)
! x* r. m/ D# V( v; V! F; F9 Y( e
, z, y& p$ R# s2 ~, C" d% S extrudeBuilder1.Section = section1% y: j- @' ?5 ?: w' }
2 m) p& s$ U/ G- o Dim direction1 As NXOpen.Direction" S0 t0 K9 |1 M, {5 l
direction1 = sess.Parts.Work.Directions.CreateDirection(sketch1, Sense.Forward, SmartObject.UpdateOption.WithinModeling)1 R3 L8 v- G! c$ {" I5 {
extrudeBuilder1.Direction = direction1
& W6 s, A) U* G$ b6 s* J( ~) R& t8 S5 J+ }3 I3 g v
extrudeBuilder1.Limits.StartExtend.Value.RightHandSide = "0"2 \. g# P% E0 z; A
extrudeBuilder1.Limits.EndExtend.Value.RightHandSide = thickness
$ D* C$ o$ ^* M1 c, |* _! X" D2 M8 O
Dim featureOptions1 As GeometricUtilities.FeatureOptions
! \( w1 M8 j, x$ m9 w featureOptions1 = extrudeBuilder1.FeatureOptions
7 ?' u; N) Y0 P4 F3 Y5 i featureOptions1.BodyType = GeometricUtilities.FeatureOptions.BodyStyle.Solid
" H! Q- ^! w5 n6 f9 }" M; i: s6 N2 m
# A0 L7 f7 H5 D- y) S% b7 ? Dim feature5 As Feature
4 W1 m1 i& ^ g3 h2 `3 D feature5 = extrudeBuilder1.CommitFeature()
x5 S/ f( Y; i
. z7 `/ z) n6 ^+ _3 o# S3 B2 k3 | extrudeBuilder1.Destroy()
& t( Q" R/ o: m" x/ ~+ m
4 Q- D/ l4 W0 R5 C( X End Sub6 m0 p3 n6 A. }) M- ^' P% l
' Main routine for this journal
& {/ ~( Y, v+ C: d! b$ [2 }; J6 n Sub Main()7 I% j5 v2 m1 o8 u
sess = Session.GetSession()
7 w) H0 d" U& y: u6 o; R+ O ufSess = UFSession.GetUFSession()( m9 v5 P7 F' G5 H
. |( i6 _5 O% k& j9 r- o; G$ T' y) q
If Not SelectFont() Then
/ ^, L/ x+ q" f+ C0 a8 ~2 Q J Return
, A8 {0 ^& d( t4 Y, j/ w End If2 R; n1 C" k3 _( \- r/ u+ i% @
If Not SelectText() Then
- \& ]+ j' \% h5 L- E8 b Return" f7 Y& H0 J+ P" Y6 C! e, \
End If8 x. z) U4 P* A- B, `& s E8 f
If Not SelectPosition() Then
8 d( z, }" @# b B% q l Return
& R% M* k' a! b& k! x( \ End If
2 u& n9 G$ B( b/ u2 d7 F A; g/ U# Q* `1 U T+ F7 N
undoMarkId = sess.SetUndoMark(Session.MarkVisibility.Visible, "Create geometry from text"): r* P9 h2 S% U" I$ |
; P- o; I6 f; J, w& K s
path = New GraphicsPath(FillMode.Alternate)5 V' f8 I5 v( M0 ?6 w; Z9 v! U
Dim zero As New System.Drawing.Point(0, 0)
- g9 G2 w9 H5 r4 q# N1 G* p4 N Dim format As StringFormat = StringFormat.GenericDefault5 w: P) N3 Q, M9 X9 A2 T
path.AddString(text, font.FontFamily, font.Style, font.SizeInPoints, zero, format)0 `3 y' }) z5 r( w
$ e) P& v K9 N. W' J( t: b$ q
Dim bounds As RectangleF = path.GetBounds()5 y, V- D. a# `/ }, z
Dim gpi As New GraphicsPathIterator(path)
. f" j! W0 H9 f2 P3 X gpi.Rewind()
. H# \+ T+ X( }6 E% F2 P; W
3 Y( q* P" l# V: ~0 L( m origin(0) -= bounds.Left
, z: Q6 C/ I6 h8 V: _0 @% S origin(1) += bounds.Bottom% q0 Z+ S& P. l( H
7 ^1 F& P# c! e Dim iSubPath As Integer
v s+ c% R: M2 Y) o( r1 j, l* a Dim subPathCount As Integer = gpi.SubpathCount& v3 {& E% y+ I7 o m+ |$ [1 g
3 ]9 o2 {' z+ V% P8 j7 [, ` For iSubPath = 0 To subPathCount - 1
! n/ v/ v3 ]* W P& w1 }- @2 s Dim mySubPaths As Integer
' O o) V6 J3 r! L* N; E+ p- f3 d5 D Dim IsClosed As Boolean' N2 u7 w' |2 `6 y7 z5 P
Dim subPathStartIndex, subPathEndIndex As Integer2 y/ j- _9 D/ p) ^/ A
Dim stpt As New Point3d4 n7 j+ k1 ^; I! N. O
Dim endpt As New Point3d1 B+ H% `7 {: f' ?& U# q- E2 g& H3 P
# R( {7 j, C1 n" b mySubPaths = gpi.NextSubpath(subPathStartIndex, subPathEndIndex, IsClosed) K4 b C! ]4 n( M+ I$ T0 @* a
Dim pointTypeStartIndex, pointTypeEndIndex As Integer7 K' F* a9 u' X- v
Do" e) K4 F# w0 Y, ~$ P
Dim subPathPointType As Byte) _& L$ r2 U N" b
Dim numPointsFound As Integer = gpi.NextPathType(subPathPointType, pointTypeStartIndex, pointTypeEndIndex)
$ d4 |2 ]0 h' T Dim type As PathPointType = CType(subPathPointType, PathPointType)9 ^) e& B8 X7 f
6 e; A, j# V, O6 |$ W* n+ G7 N- K
If type = PathPointType.Line Then
8 w9 q M3 F! n n/ r CreateLinearPath(pointTypeStartIndex, pointTypeEndIndex)
$ w, |3 s( i& q& S. R* m/ L: r ElseIf type = PathPointType.Bezier3 Then
3 U' k1 ?2 s+ I2 m CreateSplinePath(pointTypeStartIndex, pointTypeEndIndex)
( B( j! t$ u$ l3 b End If
; \) L, W8 D& b6 Z0 B Loop While subPathEndIndex <> pointTypeEndIndex y) d8 S: L* g$ V
If IsClosed Then
5 W4 [1 w) F& a8 P# P0 z& v stpt.x = path.PathPoints(subPathStartIndex).X + origin(0)# ]8 c6 h, ` i$ R' b/ p
stpt.y = -path.PathPoints(subPathStartIndex).Y + origin(1)
: h1 ]0 _5 s; ~8 s7 M" ]( {1 o3 c stpt.z = 0: v! @! {3 f' O9 `" g G8 H7 d* s
endpt.x = path.PathPoints(subPathEndIndex).X + origin(0)
+ T1 I J0 P5 d+ L endpt.y = -path.PathPoints(subPathEndIndex).Y + origin(1)
, x+ r, |; ]! v* |& ^7 x9 J endpt.z = 01 n3 s4 H" L( x% c$ `% R! r$ ?
' Do not create zero length lines
# l; A' N P" Y! B, Q r, v; L! b If Math.Abs(stpt.x - endpt.x) > 0.000001 Or Math.Abs(stpt.y - endpt.y) > 0.000001 Then
Y) O" i! f1 ]7 e5 `5 ^! w; x curves.Add(sess.Parts.Work.Curves.CreateLine(stpt, endpt))
; y+ C5 z# M- n% _6 d End If* |7 ?3 G% B3 I2 {% W9 N% k
End If
2 Q! I* {- ~8 e0 p Next4 M6 D8 s$ O0 C2 q
If SelectThickness() Then
0 h/ k3 ?" ~) g+ e, y P& | CreateSketch()3 j1 V7 Y# t) U; j; a( [7 ~+ ?- k( g U2 l1 ?
CreateExtrusion()
4 U- h7 o' F' s9 v% a3 L End If
! }4 q) Q' a6 T End Sub
7 n. y% d9 |" l% [2 w8 Q% v# A/ CEnd Module1 O4 ]1 C. @# |. W, u9 r, w
4 D( t, c6 q$ z* G5 m! ?! \+ X0 ^+ G7 D7 a
- B; U- \: |5 H0 W |
|