|
' ug刻字源码 +QQ 609719845
. Q$ o1 b3 s% }6 J8 r7 v' into geometry using a true type font and% E E. Q$ i& x0 }6 a7 r, O* L1 D
' extrude the result
2 o# b1 _( V/ }9 Z4 g. ? ^7 T% \. A; B+ V3 c
Option Strict On" K( v" A- Y. x7 \8 `% J
( h/ B9 ~( I9 e4 d# T7 j- Z) w8 u
Imports System
9 c1 _' d5 j$ G/ s" z) I, G) TImports System.Drawing
7 C, p! `& j* |; jImports System.Drawing.Drawing2D. E- ~/ D; Z- c4 [6 Z6 z" `' Y
Imports System.Windows.Forms
2 h2 K- W+ O1 EImports System.Collections' Q g! g; y* Z8 a* P$ o1 Q' y
Imports NXOpen8 R7 X- D( ~* b% V* A% A/ Z9 Z" [
Imports NXOpen.Features: \% b2 H" G7 I' D# }. k
Imports NXOpen.UF
+ r a& D# L" H0 {Imports NXOpen.Utilities7 o4 g: x A( E( ?* p" |
Imports NXOpenUI
5 X! d/ ]& {8 J; T/ w/ r% y0 V: J+ i
/ X8 s. h0 C- ^8 _9 FModule DrawText( w- n2 S- ~" s* S, [( u7 s' O
/ n) o0 m% `1 M1 W O" F Private sess As Session
3 s; x, K$ P* v Private ufSess As UFSession
4 q) @( S( [) b/ U1 w8 i+ l Private origin(2) As Double) [* |4 U" }2 D$ U. Q; m0 |
Private path As GraphicsPath' F% S% ~; d; |8 B2 ~/ [4 ^2 @
Private text As String0 e$ |) c3 ~5 U
Private font As font: c% q1 L/ K5 c! H, T! v% N
Private curves As New ArrayList [0 E# C' i( z5 Z4 E6 {
Private sketch1 As sketch
" y7 X9 x: O% G% C' Q Private thickness As String. q# Z- E( l% c ~
Private undoMarkId As Session.UndoMarkId3 z' y3 J3 y; g# \
$ B0 t9 a( ]: I6 z E& S* U5 _
' Prompt the user to select a font.
{! A8 J" V( n8 S; L ' Return True if successful9 q) R- P B! P) ~. x( m
' The Module level variable 'font' is set to the resulting font.& L5 l8 F3 |- k7 c
Function SelectFont() As Boolean
: ?( o2 d) Z. g Dim fontDlg As FontDialog = New FontDialog
W' ^7 e# a) \# H, ^) ~9 m4 @% p9 H- ]
SelectFont = False3 @6 n0 C D" ]. Q
If fontDlg.ShowDialog() = DialogResult.OK Then
- m! F% @9 l$ A8 B* I. ]/ \ font = fontDlg.Font
/ f" V4 y& n/ u4 P& P, p. u/ { SelectFont = True
( e/ o4 L$ ]4 T5 n8 P5 X0 O End If
4 k; C* D z* [4 {5 h End Function
- }0 Y3 u1 @& J" \ ' Prompt the user to select a screen position
6 ~& q( S% N$ j- S5 x; L. @1 J. m ' Return True if successful
( V5 A6 d. m8 ?. p: c ' The Module level variable 'origin' is set to the resulting point.! `8 o+ V8 J" f3 B
Function SelectPosition() As Boolean
' ]$ N' x: M a Dim view As Tag
_) Q, G- F" P0 D7 N M2 Q( h Dim response As Integer
; d' z2 B- f+ [3 v% H9 h" T
4 k* x- Q& c( Z9 i* y( r ufSess.Ui.LockUGAccess(UFConstants.UF_UI_FROM_CUSTOM)( a% i, z6 K- D/ n+ a6 D& m
SelectPosition = False
( b% ~- I: N( s- A Try
8 w& y7 ?# C5 R/ n+ J ufSess.Ui.SpecifyScreenPosition("选择字体", Nothing, IntPtr.Zero, origin, view, response)
. e" }/ h; ?7 N- }* Z If response = UFConstants.UF_UI_PICK_RESPONSE Then, K3 I" a5 w$ c( h8 v1 K
SelectPosition = True
! Z; W* u' A9 A2 c End If
+ Y, C/ E( |6 f5 e Finally
# b, n/ }1 ?8 k1 M# F6 ^# C ' Restore UI state always including in case of error.% J% `. Y9 A) p
ufSess.Ui.UnlockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)
; B# k' I- `9 S2 A End Try
9 N$ e* w2 P2 n4 _4 ~: a+ Z7 s" k End Function
8 U8 z2 E- E. s( K ' Prompt the user to input a text string to convert. X; D; K' R) D
' Return True if successful4 }" W: h" y4 d" g( I, H
' The Module level variable 'text' is set to the resulting string., y6 w( c0 D9 B/ D2 q' m2 S. ^
Function SelectText() As Boolean0 C+ [4 [! \# m7 v: `# V
text = NXInputBox.GetInputString("输入文字", "Enter String To Convert")/ S! J, T$ E2 ?! F
SelectText = False5 V# C& n7 _0 b! X" H1 p
If text.Length <> 0 Then* H. v c4 V# A# R( m
SelectText = True( O# y; Z0 @1 _* l( M
End If
5 P- B( y$ j2 Q) i9 x/ J End Function
4 s; v0 p1 _% }- n4 E! q3 d2 b ' Prompt the user to input an expresion text string to convert.$ Q3 M# p I+ N: q
' Return True if successful
( @; T" ?' E: g7 A$ U5 \ ' The Module level variable 'thickness' is set to the resulting string.
/ h- `" q) X; m- G Function SelectThickness() As Boolean
4 @% p) T5 w8 N' P* z thickness = NXInputBox.GetInputString("输入高度", "输入高度")6 k2 o2 B' H4 P2 i/ o$ j8 t
SelectThickness = False5 G* ~4 p* W5 Y' k5 q
If text.Length <> 0 Then6 g# _6 C9 F6 m
SelectThickness = True
1 Q% _8 ]6 y& G1 P3 N2 \ End If- R9 {1 `- n& m8 |+ z0 E; h! K9 y
End Function: Y& v1 V$ \1 E$ p# p L# W
' Given a subset of the graphics path between the given indices
/ L) X5 Z5 _% G. w$ W ' create lines between the points in the path.
! q+ E3 |+ n# ~9 V3 j ' Assumes that caller has selected an appropriate section of the path./ Z( N$ C. j7 V! I) ]& ^$ U& x
Sub CreateLinearPath(ByVal startIndex As Integer, ByVal endIndex As Integer)
+ a' ~! Q7 `! s/ J7 M) x. p Dim j As Integer. U* B8 v1 e" P+ _% I3 \3 u
For j = startIndex To endIndex - 1
. N2 L4 Y, |5 w2 M E6 [3 r! J Dim stpt As New Point3d
6 A" w! d, z2 l7 X; X Dim endpt As New Point3d- [4 s- F* I6 S! b' D* \7 M( s' y
stpt.x = path.PathPoints(j).X + origin(0)
: g$ G& f1 V2 {; }9 ` stpt.y = -path.PathPoints(j).Y + origin(1)
& y9 v1 C, R' I/ K stpt.z = 0
" e) b% P' C5 c* I endpt.x = path.PathPoints(j + 1).X + origin(0)
, f, w v& }0 U endpt.y = -path.PathPoints(j + 1).Y + origin(1)
0 ~- R0 Q; m8 T( [0 R endpt.z = 06 V ~ I% c a) d$ M/ L0 N
curves.Add(sess.Parts.Work.Curves.CreateLine(stpt, endpt))
# X9 o, u) F' k* k- R' w3 ~ Next
5 E0 ^# l9 B+ ]( A" W/ c+ Q6 ]( g End Sub: J6 A$ l. m \; ~7 T3 N4 @2 w
' Given a subset of the graphics path between the given indices 8 m* B: r6 Q0 Q/ I; j
' create splines between the points in the path.
7 O) a% R8 X+ m) g$ _" F1 M9 i ' The path contains bezier segments and this converts then to B-splines.
- |4 n; y' R. p' _# g) ` ' Assumes that caller has selected an appropriate section of the path.5 {9 z" r" a+ h8 W
Sub CreateSplinePath(ByVal startIndex As Integer, ByVal endIndex As Integer)
+ C0 q! a: `3 |4 ~; S9 y Dim j As Integer
5 w, |$ _/ T5 d( S/ |# N6 G' _ For j = startIndex To endIndex - 1 Step 3
9 {5 S& Z& L; f/ g$ ] Dim poles(3, 3) As Double
4 F7 w9 c# o' p& E5 L, h, ^7 r8 s+ y Dim k As Integer
4 x4 Q+ x) O1 w For k = 0 To 34 @- g$ ~2 t: g% b) {7 S5 [
poles(k, 0) = path.PathPoints(j + k).X + origin(0)
- f3 w! e4 T, [ poles(k, 1) = -path.PathPoints(j + k).Y + origin(1)
! U$ A( U$ u6 f6 C poles(k, 2) = 0) x% ^# p( n* C# u
poles(k, 3) = 1" e( O+ j# O/ Z# x
Next
6 ?8 \4 ?- x( p0 S# G Dim knots() As Double = {0, 0, 0, 0, 1, 1, 1, 1}3 w3 I; |; [5 i7 ]/ S
Dim spl As UFCurve.Spline
( Y% k9 R. j; b* ^0 s0 U Dim spline As Tag
i" c0 M# b2 O) [. Z3 R+ D5 r! I Dim num_states As Integer
2 w+ c& e( U; Y$ [$ R# R Dim states() As UFCurve.State = Nothing$ `! c. T ?5 w/ p' y
spl.start_param = 0" }+ U8 v$ k/ D" l" x( {
spl.end_param = 1
" ^5 k, p+ D" {$ } spl.is_rational = 03 @0 ~7 o4 ?, Q3 @, ^/ u6 B4 s% U
spl.num_poles = 4+ ^2 v9 q: S) d! r
spl.order = 4
* \4 ]3 X- y. d spl.knots = knots! N: z/ i+ _. X) K4 _0 U; g p
spl.poles = poles4 b' ?3 Q! ^* S1 o. M- U a
ufSess.Curve.CreateSpline(spl, spline, num_states, states)
8 i$ ], B4 i e; r W4 O9 w8 ^ curves.Add(NXObjectManager.Get(spline))
0 L2 }9 q1 G! x* g Next4 w1 m/ h. F2 O9 c( c3 I; W
End Sub
( w* n) ?/ `" J8 E2 g8 a ' Create a sketch and add all curves we've created to it.9 ~) L5 X' |( h/ ~
' Most of this was created by recording create a sketch and editting the result.) _6 Y9 X1 U, m" h" a4 n3 l0 X- d5 X/ G. H
' Retries with different sketch names to avoid duplicate names.
& a7 C1 z" V) v& V4 ]$ w: S p1 ]/ a Sub CreateSketch()
( X4 z$ |! N- M3 J4 f* V Dim theSession As Session = Session.GetSession()2 L8 o# b; L! F) a
Dim workPart As Part = theSession.Parts.Work" B: ?: Z$ P% _" Y! S& q/ y
Dim displayPart As Part = theSession.Parts.Display
: Y$ V9 z9 K- X$ O8 s1 u& C( d# L
' E8 m8 v$ x8 j; z$ F Dim markId1 As Session.UndoMarkId
, B% G5 _& R2 Q9 p, K markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")5 W# P; A2 Q/ Y; U! K
$ v) m8 E) p6 v+ A) u+ }5 x Dim nullSketch As Sketch = Nothing
/ O0 Y' O, M& j3 g2 |7 X i) E/ Y& T" o2 ^2 n7 v
Dim sketchInPlaceBuilder1 As SketchInPlaceBuilder* K# F. X: D8 f) J x1 f
sketchInPlaceBuilder1 = workPart.Sketches.CreateSketchInPlaceBuilder2(nullSketch)
! Z! @4 x, V! B( |7 c6 X$ q/ h
2 i+ v* Y2 c7 s& f6 [8 R Dim unit1 As Unit = CType(workPart.UnitCollection.FindObject("Inch"), Unit)
$ S. v/ ^: z/ Y8 `% a% u/ O. V' ^. ?- s/ r# S
Dim expression1 As Expression
% y: Z/ d, f% _0 R4 E expression1 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)4 o" z* i$ c" L' T9 o3 ?% A4 z
' o7 m% g- x! c* G- i Dim expression2 As Expression
$ Y" t% |) W3 D5 H- Q expression2 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
& ?$ H3 r8 L! U. w: _" f# E' W% o0 t( L
theSession.SetUndoMarkName(markId1, "'Create Sketch Dialog")& t# O$ ^$ k6 K. l
$ V2 O5 T$ t; B) g; U$ s8 V Dim markId2 As Session.UndoMarkId
9 z5 } M1 J- @" c% F1 J markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Create Sketch")5 c+ E& {) i# ]. P% M1 L
$ V! W7 C% T; F2 b6 V
theSession.DeleteUndoMark(markId2, Nothing)
4 @. g1 w+ U) Z- d+ x! {
7 W( u0 j$ Z2 S1 W- C/ X Dim markId3 As Session.UndoMarkId- g- M1 V" Z. E" X
markId3 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Create Sketch")
8 M5 t3 V, d4 i$ I# b( t
9 s# u6 D* D' d/ I ' Inferring constraints and auto dimensions may take long time and is not really required for drawing text. 6 r7 }2 J. u) ]$ p, Z- v% H& f' J
theSession.Preferences.Sketch.CreateInferredConstraints = False
% X% S8 @- v/ ]0 F theSession.Preferences.Sketch.ContinuousAutoDimensioning = False
* n2 m1 g! }8 b0 a% o7 m8 K) }* ^ theSession.Preferences.Sketch.DimensionLabel = Preferences.SketchPreferences.DimensionLabelType.Expression
8 I9 |4 N; _- N5 C1 P9 r theSession.Preferences.Sketch.TextSizeFixed = True5 i1 k% H, P+ |+ v1 c
theSession.Preferences.Sketch.FixedTextSize = 0.12$ P. V P& n; A) ~
theSession.Preferences.Sketch.ConstraintSymbolSize = 3.0
: H: ~2 K4 P9 A8 U theSession.Preferences.Sketch.DisplayObjectColor = False6 k) S" W% ^ W# Z* K
theSession.Preferences.Sketch.DisplayObjectName = False
( _- ]3 d2 M- V r7 g8 s6 u* H9 P7 P0 c4 K
Dim nXObject1 As NXObject% N9 ]: d& k! l' A2 @9 J
nXObject1 = sketchInPlaceBuilder1.Commit()
+ u+ v9 W _3 H3 G sketch1 = CType(nXObject1, Sketch)# I, K( s$ R8 f
: v! _& p) U ~ J- U, Y
Dim markId4 As Session.UndoMarkId
, k3 v( M+ B. q" W( _, Y markId4 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "update")
7 x; o1 v' A! T S2 S( s* a& I# `6 x
Dim nErrs1 As Integer
4 U+ X; N+ _* l6 ]8 S nErrs1 = theSession.UpdateManager.DoUpdate(markId4)
1 M W: K! L3 i# ]5 O+ W L R
/ f1 H4 q4 Y6 s+ ~ sketch1.Activate(sketch.ViewReorient.False)7 P- p6 R% y9 e4 S, G. r* f- B
* A( E' m) B5 v1 V$ \ Dim curve As DisplayableObject3 M8 i2 d- @7 V/ x0 u
For Each curve In curves
/ b5 K7 Y3 Y' Y5 o Try$ A& `9 G" G8 s7 Z" B7 Q# d
sess.ActiveSketch.AddGeometry(curve)* C y3 o/ B1 O2 A; ~, @- w+ @ S
Catch ex As Exception
: d5 ~, F- A# V2 l6 n* G W, S MessageBox.Show("Could not add: " + curve.ToString + " to sketch " + ex.Message)
$ @( `2 ]- K6 r7 U0 I4 d0 R End Try
) h8 B7 \$ F! E! p/ i Next$ }' v) _( b+ O5 t3 t8 A; f
" Z* I# d; d# Y( u! ~ C g e' o5 c# P sess.ActiveSketch.Deactivate(sketch.ViewReorient.False, sketch.UpdateLevel.Model) T+ _/ y) A, Y
. H) T5 S, B7 q2 M2 G theSession.DeleteUndoMark(markId3, Nothing)7 r% v/ l% }5 q8 a0 [9 U; N+ ?* k
theSession.SetUndoMarkName(markId1, "Create Sketch")
S- p3 ^1 R. o sketchInPlaceBuilder1.Destroy()
7 u( k! j# [0 j: ^. h5 \6 f1 ?
Try+ _' E1 T! X; u; K: E
' 'Expression is still in use.# I( z, i1 \7 T* w2 V2 V; H+ e
workPart.Expressions.Delete(expression2)* H3 A/ H2 S, g; j8 U7 _2 `
Catch ex As NXException
# ~+ K( P3 G; J ex.AssertErrorCode(1050029)( d `0 Y8 I2 i/ u, F$ [. R' Y1 Y
End Try
" V3 I3 a1 L& I
B t+ d) S3 F1 C% h) Y# v: |$ V Try
: ], [+ |9 J! I2 L6 H' P$ Q% i ' 'Expression is still in use.
( H$ }- k5 s5 V workPart.Expressions.Delete(expression1)' ^' b. D, l$ \$ w+ D
Catch ex As NXException
% L. a& J2 p3 G ex.AssertErrorCode(1050029)
$ Z/ x1 w8 I* h3 g, }( ^ End Try5 J0 N, m, j" M8 E
1 P+ i! i% O9 V& X9 G/ P
End Sub
% `! F- s$ |; i4 m- t$ R% G ' Extrude the sketch1 |7 m4 C: R/ {$ Z2 c3 t, J
Sub CreateExtrusion()
+ e+ V: ~1 R( ~ Q2 S
, S9 Y v( s: i+ F1 ?4 N# U Dim nullFeature As Feature = Nothing& E4 w& ^& G1 p2 c
' S$ k9 i( H' Z8 C; d( ?0 u, e Dim extrudeBuilder1 As Features.ExtrudeBuilder
$ {# Q: ^( \6 I: p0 ?! n1 i extrudeBuilder1 = sess.Parts.Work.Features.CreateExtrudeBuilder(nullFeature)' J( P. H6 s F6 X! _. q
/ Q, I8 R' k5 V B2 J2 X4 f0 [
Dim section1 As Section' g! H, c) L' L5 o% ^) o
section1 = sess.Parts.Work.Sections.CreateSection(0.000001, 0.001, 0.5)9 i9 u% V) D V
! I4 }. |% F. ?) d
Dim featureArray1(0) As Feature! J: _' a: p& W* y, {
featureArray1(0) = sketch1.Feature$ X; y, D0 Q, x- _( O7 }- ~
Dim curveFeatureRule1 As CurveFeatureRule
" K6 A5 ]4 J' K7 I/ M# i1 I curveFeatureRule1 = sess.Parts.Work.ScRuleFactory.CreateRuleCurveFeature(featureArray1)
$ o/ X2 E. \, |3 f- ~+ R) B) u: g1 p+ o+ j i1 Z8 t
Dim rules(0) As SelectionIntentRule* e) \1 B! z# ~+ T! l
rules(0) = curveFeatureRule1
1 n( x& i$ Z! u* b Dim geoms() As NXObject = sketch1.GetAllGeometry()
! H) P" M" C9 ]! _ X" N9 D Dim helpPoint As Point3d = New Point3d(0, 0, 0)8 }: j- t F: p9 n/ a7 Q
section1.AddToSection(rules, geoms(0), Nothing, Nothing, helpPoint, Section.Mode.Create)
& ~9 \4 P# e% ^- J; g3 k1 x0 P" D/ Z
extrudeBuilder1.Section = section17 N* F* d; u6 | B6 O0 f; m& R& r) k; a
9 a( V6 F2 W! L* d+ E" R! e4 b/ E
Dim direction1 As NXOpen.Direction
. A. U F( `! X! o1 e! Y9 K& o direction1 = sess.Parts.Work.Directions.CreateDirection(sketch1, Sense.Forward, SmartObject.UpdateOption.WithinModeling)1 N5 V& j, F, Z8 s
extrudeBuilder1.Direction = direction1
B( K7 h; w" o( n+ W* J0 R. q
+ k. l; m) }: K: O& k. T! I1 u extrudeBuilder1.Limits.StartExtend.Value.RightHandSide = "0"
) k2 p( m R* N extrudeBuilder1.Limits.EndExtend.Value.RightHandSide = thickness
, Z: Z' u6 } J. k
7 m! f) o6 j7 `" ` Dim featureOptions1 As GeometricUtilities.FeatureOptions
. @+ \4 b; c8 l3 q. v* u featureOptions1 = extrudeBuilder1.FeatureOptions
' W& a8 _; d/ M+ P/ X. E; L, _4 \ featureOptions1.BodyType = GeometricUtilities.FeatureOptions.BodyStyle.Solid
: O8 `' c( S# c6 N, R8 P! ^- h! q( |' R* @ A
Dim feature5 As Feature& t( e' G* S& O. x9 d. l
feature5 = extrudeBuilder1.CommitFeature()
( X# C6 Q' [$ @" K! ^
' F% [0 s* L: A% T* z- o extrudeBuilder1.Destroy(), | W! J- p; e7 I# n
3 p V$ ~/ v$ c4 d% d
End Sub" S+ ?- Z0 l) {7 Q& U* N6 d
' Main routine for this journal- h( [. X' ^3 ]& [
Sub Main()/ b" X7 N9 P# O1 Y. `2 g
sess = Session.GetSession()+ \. s. x9 \. C% z g
ufSess = UFSession.GetUFSession()
1 l1 A X }$ N. O9 g+ S
7 Y. N$ T' j1 ^ If Not SelectFont() Then7 U% n3 I/ S3 |
Return# Y& h: K. n; Q" x$ F
End If
8 N+ P/ [% v8 A, S4 d If Not SelectText() Then
f6 [, l3 j4 O Return6 n @+ h3 u5 o" y, T
End If
: Y. `# `5 |0 ], _: [6 d If Not SelectPosition() Then
7 q: P( X2 m1 v5 W Return
7 z2 T6 Z/ N' `3 s# `6 S0 n0 b7 \( @ End If
0 y9 q+ z, d k2 g$ ]/ M: A N2 I, i: R
undoMarkId = sess.SetUndoMark(Session.MarkVisibility.Visible, "Create geometry from text")3 }# _5 |3 d% q0 i" q2 _2 w0 O
3 \4 s8 b8 e5 T" V
path = New GraphicsPath(FillMode.Alternate)% x/ p$ I% M0 `$ d# k5 T
Dim zero As New System.Drawing.Point(0, 0)
( {& ]. u0 r( s4 b; { Dim format As StringFormat = StringFormat.GenericDefault4 q* v# _5 P5 T9 ?4 q( Y8 g
path.AddString(text, font.FontFamily, font.Style, font.SizeInPoints, zero, format)5 \) H% @% f q# C% Q, K( n W
5 ^; ?2 ^2 o$ I# R Dim bounds As RectangleF = path.GetBounds()* }( @' A0 b1 v- a$ y, v
Dim gpi As New GraphicsPathIterator(path)
% ^9 S, @# L! p$ |4 L; }6 S$ ~ gpi.Rewind()
- c; I- G5 Y6 C8 L$ Q7 M
5 e5 S" |5 {3 K, a3 p. Q origin(0) -= bounds.Left3 Q' v( Z6 r7 o; z# v; t1 q0 f
origin(1) += bounds.Bottom
5 l: _6 S8 T1 l3 v6 p" q' l/ J6 K2 V1 D, G( R
Dim iSubPath As Integer
2 B" Q6 ~( p( x3 R4 D Dim subPathCount As Integer = gpi.SubpathCount
2 I+ T9 u9 p. t- ]) [3 V' c7 P: z1 F, O
For iSubPath = 0 To subPathCount - 1
0 ?8 v: N N8 I) o4 u& X5 ], b# N, Y Dim mySubPaths As Integer
3 F% a* ?0 X7 { y Dim IsClosed As Boolean! |$ M2 \# B0 u
Dim subPathStartIndex, subPathEndIndex As Integer
1 y+ {2 Q5 P7 |" A* U6 Z. e+ ` Dim stpt As New Point3d' B& d! i, R8 r- e( [- |
Dim endpt As New Point3d
- x) q3 O. F" w: @
$ a, E, D; k% z' } mySubPaths = gpi.NextSubpath(subPathStartIndex, subPathEndIndex, IsClosed)7 ]# E6 _+ x7 U7 k. m
Dim pointTypeStartIndex, pointTypeEndIndex As Integer3 j/ h4 X. B5 G: w0 n6 J
Do
9 V, n1 w8 h& J6 s, Y Dim subPathPointType As Byte# |3 `" T3 d; n
Dim numPointsFound As Integer = gpi.NextPathType(subPathPointType, pointTypeStartIndex, pointTypeEndIndex)+ U& l; C8 |1 K" w
Dim type As PathPointType = CType(subPathPointType, PathPointType)
( E, r( c+ Y7 T- t, {7 ?
. ?7 z Q3 u; m, F4 J: m If type = PathPointType.Line Then
/ C, K6 |' \2 F m CreateLinearPath(pointTypeStartIndex, pointTypeEndIndex)
6 u# O* g3 L3 Z$ c$ O0 u% l' m ElseIf type = PathPointType.Bezier3 Then! P: l4 K9 A" `, Y
CreateSplinePath(pointTypeStartIndex, pointTypeEndIndex)4 s% V% p0 C, q* ]# L2 I
End If
( s0 K1 O" x7 J9 z Loop While subPathEndIndex <> pointTypeEndIndex
: U2 d$ {. [2 W9 x9 }; P If IsClosed Then1 I* n. v0 n( b% w, H0 H
stpt.x = path.PathPoints(subPathStartIndex).X + origin(0), K* L( j) d% {# L1 q g! Y f
stpt.y = -path.PathPoints(subPathStartIndex).Y + origin(1)! X# ]% x! ]# Z( g% u" q
stpt.z = 09 @$ @; B3 V6 E! t1 R+ l6 ~$ J
endpt.x = path.PathPoints(subPathEndIndex).X + origin(0)
8 c1 \2 y j6 ] endpt.y = -path.PathPoints(subPathEndIndex).Y + origin(1)
( d5 L# ]( A8 _6 ^7 g6 K9 N endpt.z = 03 X' M( e+ k. c* x& Z
' Do not create zero length lines
/ \0 E9 j) U0 N3 y3 Y* b If Math.Abs(stpt.x - endpt.x) > 0.000001 Or Math.Abs(stpt.y - endpt.y) > 0.000001 Then2 F: y0 c* K: s7 K
curves.Add(sess.Parts.Work.Curves.CreateLine(stpt, endpt))
+ W8 a. m* C1 \; I1 _ End If
. A) H6 f& M8 }1 p End If
& N9 x* c1 y- k1 M; ^5 K9 V2 Y Next
/ _) C/ T/ ?/ G( T, S/ |5 L If SelectThickness() Then! f0 e W4 q8 g- ^: d& J. D' T
CreateSketch()
$ L, r n/ e+ p; F+ u- J CreateExtrusion()% f; m8 ~) a4 [( Z. O8 p
End If) N/ B3 f) H% ~* Z
End Sub
) e1 c, k; V$ n" H/ i2 Q7 Q$ dEnd Module H6 N$ A( M4 |
. k, ^% n5 u# @8 L* {% S! ^4 A) T" s7 a! d& M# w9 {" e
- C+ a2 i' A$ I: h! R1 U0 Q6 ^
|
|