Welcome, Guest. Please login or register.
May 16, 2012, 03:25:18 pm
Home Help Search Login Register
News: Remember to do a search before you ask a question!!!

+  TurboCAD Forums
|-+  SDK Corner
| |-+  SDK General Discussion
| | |-+  Add Curve Spline
« previous next »
Pages: [1] Go Down Print
Author Topic: Add Curve Spline  (Read 1797 times)
MikeCrown
Newbie
*
Posts: 11


« on: February 10, 2010, 04:00:30 am »

Hi Everyone  Grin,
I'm trying to create a vb.net plugin to draw circles depending on data extracted from an excel sheet, however i've hit a bit of a hurdle.

What I'm wanting to do:
 - Create a Curved Spline
 - Add 4 Fit points (not control points), top bottom left right.
 - Close the spline (join the first and last points).

Heres what I have so far:
Code:
        tcDrawing = tcApp.ActiveDrawing
        tcView = tcDrawing.ActiveView
        tcGraphics = tcDrawing.Graphics
        Dim tcSpline = tcGraphics.AddCurveSpline(0, 10, 0)
        tcVertices = tcSpline.Vertices
        With tcVertices
            .Add(10, 0, 0, True, True)
            .Add(20, 10, 0, True, True)
            .Add(10, 20, 0, True, True)
            .AddClose(True)
        End With
        tcSpline.draw()

What Happens:
This sort of works so long as the .AddClose is commented out, but then obviously the spline isn't closed.
And the vertices seem to be Control points rather than Fit points.

Any help would be greatly appreciated. I've been looking everywhere but cant seem to find any valid documentation.

Cheers

Mike at Crowns



Logged
ibruethsch
Jr. Member
**
Posts: 85

Bernd


« Reply #1 on: February 11, 2010, 07:01:33 am »

Hi Mike
I used the addcurvespline in a VB-Macro before. I remember it was not reliable, maybe a bug in the SDK.
I tested your example with very odd results.
Code
Dim etc….
        Set tcspline = app.ActiveDrawing.Graphics.AddCurveSpline(0, 0, 0)
        Set tcvertex = tcspline.Vertices.Add(0, 10, 0)
        Set tcvertex = tcspline.Vertices.Add(10, 10, 0)
        Set tcvertex = tcspline.Vertices.Add(10, 0, 0)
        Set tcvertex = tcspline.Vertices.Add(5, -2, 0)
        Set tcvertex = tcspline.Vertices.Add(0, 0, 0)

        Set tcvertex = tcspline.Vertices.AddClose(1, 1, 1)

ActiveDrawing.Views.Refresh

end

I add the vertex Endpoint = startpoint. Without that TC crashes.
Run the macro in Debug-modus it does what it should do. After selecting the Spline and moving it it is closed.
Running the macro in the normal Modus, or create an .exe an run that, TC crashes!!

Bernd

Logged
MikeCrown
Newbie
*
Posts: 11


« Reply #2 on: February 12, 2010, 05:34:24 am »

Thanks for the reply,
However Im still at a loss as to how to use Splines.
I tried the code above and it drew something, then when I tried to select it (ctrl+a) I got a message saying "object extents are invalid, objects deselected" Huh

Does anyone know of some documentation for the SDK?, all I can find is a help file in the SDK folder which  says
"The user must use subsequent Graphic.NextPoint calls to add segments to the Graphic object, and a Graphic.Finish call to complete the Graphic object."
As far as I can tell there arent any methods called NextPoint or Finish!
« Last Edit: February 17, 2010, 05:35:21 am by MikeCrown » Logged
kchapman
Administrator
Full Member
*****
Posts: 201


« Reply #3 on: February 16, 2010, 09:32:37 pm »

Hi Mike,

First, I'm sorry, but you can't draw fit-point splines through the SDK. There's not really an underlying fit spline type -- when you draw a "fit-point" spline manually, TurboCAD converts it to a control-point spline behind the scenes; just select it with the Editor tool after you've drawn it and you'll see what I mean.

Now, to draw a closed control-point spline, you're almost there -- you're setting all your points correctly. Just be sure to set the graphic's "SPLINECLOSED" property to 1. Then you won't get the sudden changes in shape after you select the spline.

Here's a VBScript example:
Code:
'Spline_closed.vbs'
'Draws a closed control-point spline'
Dim app
Dim drw
Dim grf
Dim verts
Dim props
Set app = GetObject("", "TurboCAD.Application")
Set drw = app.Drawings.Add
Set grf = drw.Graphics.Add("TCW30Curve", "TCW30Curve")
Set verts = grf.Vertices
Set props = grf.Properties
props.Item("$SPLFRAME").Value = 0 'no visible control frame'
props.Item("$SPLINETYPE").Value = 0 '0=spline, 1=bezier'
props.Item("SPLINECLOSED").Value = 1 ' required if you want the spline to be closed.'
verts.Add 0, 0, 0
verts.Add 10, 0, 0
verts.Add 10, 10, 0
verts.Add 0, 10, 0
verts.AddClose
grf.Draw 
Set props = Nothing
Set verts = Nothing
Set grf = Nothing
Set drw = Nothing
Set app = Nothing
Logged
MikeCrown
Newbie
*
Posts: 11


« Reply #4 on: February 17, 2010, 05:40:08 am »

Thanks for the help, I shall try that code out shortly.
However I've managed to get Beziers working (same as my original code, only replacing AddCurveSpline with AddCurveBezier) so I'm using those now. Probably more appropriate for the shapes I'm making.

Cheers
Mike at Crowns
Logged
MikeCrown
Newbie
*
Posts: 11


« Reply #5 on: February 19, 2010, 07:45:46 am »

Thanks for the reply, the code you suggested works well. Wink
Logged
Pages: [1] Go Up Print 
« previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.055 seconds with 17 queries.