alexit
Mechanical
- Dec 19, 2003
- 348
I am using the following snippet of code to plot point data from a bit of calculation software. These points are not described by an equation, and because the points are very close together SW will not create a spline through them. Dropping every N points doesn't work as they are not very predicatable and the spline misrepresents the points badly.
Unfortunately I am finding the CreateLine2 function is extremely slow, about 2 second each little line, or over an hour total. Anyone have a suggestion to improve the speed?
Val = swModel.GetUserPreferenceToggle(swInputDimValOnCreate)
swApp.SetUserPreferenceToggle swInputDimValOnCreate, False
swModel.InsertSketch2 True
swModel.ClearSelection2 True
swModel.CreateCircleByRadius2 0, 0, 0, (ID / 2)
swModel.AddDiameterDimension2 (ID / 2), (ID / 2), 0
swModel.CreateCircleByRadius2 0, 0, 0, (OD / 2)
swModel.AddDiameterDimension2 (OD / 2), (OD / 2), 0
swApp.SetUserPreferenceToggle swInputDimValOnCreate, Val
swModel.InsertSketch2 True
swModel.ClearSelection2 True
For i = 1 To j - 1
p1x = points(1, i) * 0.0254
p2x = points(1, i + 1) * 0.0254
p1y = points(2, i) * 0.0254
p2y = points(2, i + 1) * 0.0254
swModel.CreateLine2 p1x, p1y, 0, p2x, p2y, 0
Next i
Thanks for all your help!
Unfortunately I am finding the CreateLine2 function is extremely slow, about 2 second each little line, or over an hour total. Anyone have a suggestion to improve the speed?
Val = swModel.GetUserPreferenceToggle(swInputDimValOnCreate)
swApp.SetUserPreferenceToggle swInputDimValOnCreate, False
swModel.InsertSketch2 True
swModel.ClearSelection2 True
swModel.CreateCircleByRadius2 0, 0, 0, (ID / 2)
swModel.AddDiameterDimension2 (ID / 2), (ID / 2), 0
swModel.CreateCircleByRadius2 0, 0, 0, (OD / 2)
swModel.AddDiameterDimension2 (OD / 2), (OD / 2), 0
swApp.SetUserPreferenceToggle swInputDimValOnCreate, Val
swModel.InsertSketch2 True
swModel.ClearSelection2 True
For i = 1 To j - 1
p1x = points(1, i) * 0.0254
p2x = points(1, i + 1) * 0.0254
p1y = points(2, i) * 0.0254
p2y = points(2, i + 1) * 0.0254
swModel.CreateLine2 p1x, p1y, 0, p2x, p2y, 0
Next i
Thanks for all your help!