TurboCAD Forums

The Ultimate Resource for TurboCAD Knowledge

Register
 
The purpose of these forums is to discuss TurboCAD.  Please keep the discussion of other products to compatibility issues or how the other software’s can be used with TurboCAD.


3D Polyline Creation
Read 1015 times
* October 15, 2014, 03:53:24 PM
I am working with Visual Express 2010 and TurboCAD v18.2 and want to add a 3D polyline but can't figure out how. 

I can create a ImsiGraphicType.imsiPolyline and specify 3D points but the polyline only renders as 3D if I am in Advanced Rendering and not in Wireframe.  Also in the selection info palettes the object always shows as a polyline not a "3D Polyline"

Assuming I've managed to open a drawing and assign it to myDrawing I am using the following code:
 
--------------------------------------------------

 Dim myDrawing as IMSIGX.Drawing
 Dim Grphc As IMSIGX.Graphic

 'Code to link to TCAD application and open a drawing would go here

 Grphc = myDrawing.Graphics.Add
 Grphc.Vertices.Add(1, 1, 1)
 Grphc.Vertices.Add(1, 10, 1)
 Grphc.Vertices.Add(1, 10, 10)
 Grphc.Vertices.Add(10, 10, 10)

---------------------------------------------------------

I've looked through and tried various Graphics.Add... methods but can't seem to fine one that give me a 3D polyline.

Any help would be appreciated.  Thanks


Logged


* October 16, 2014, 03:14:02 PM
#1
I figured it out.  I need to assign graphic.vertices.useWorldCS = True before adding the vertices to get a 3D Polyline.

Below is a simple console application created in Visual Studio Express 2010 with imsigx18.dll added as a reference.

Code: [Select]
Imports IMSIGX

Module Module1

    Sub Main()

        Console.WriteLine("Starting")

        Dim TCADApplication As Application
        Dim TCADDrawing As Drawing
        Dim TCADGraphic As Graphic

        Console.WriteLine("Creating TurboCAD Application Object")
        TCADApplication = New Application
        TCADApplication.Visible = True

        Console.WriteLine("Creating New Drawing")
        TCADDrawing = TCADApplication.Drawings.Add()

        '----> First Polyline 2D

        Console.WriteLine("Creating First Graphic (will be polyline)")
        TCADGraphic = TCADDrawing.Graphics.Add()

        Console.WriteLine("Adding vertices (all z coordinates = 0")
        TCADGraphic.Vertices.Add(1, 1, 0)
        TCADGraphic.Vertices.Add(10, 10, 0)
        TCADGraphic.Vertices.Add(20, 10, 0)

        Console.WriteLine("Drawing the Graphic in current view")
        TCADGraphic.Draw()

        Console.WriteLine("Adding Graphic to selection collection")
        TCADGraphic.Select()

        '----> Second Polyline 3D

        Console.WriteLine("Creating Second Graphic (will be 3D polyline)")
        TCADGraphic = TCADDrawing.Graphics.Add()

        Console.WriteLine("Setting vertices to use world coordinate system.")
        TCADGraphic.Vertices.UseWorldCS = True 'By setting UseWorldCS to True and then assigning z coordinate <> 0 causes polyline to become 3D Polyline

        Console.WriteLine("Adding vertices (all z coordinates = 0")
        TCADGraphic.Vertices.Add(-1, -1, 0)
        TCADGraphic.Vertices.Add(-10, -10, 10)
        TCADGraphic.Vertices.Add(-20, -10, 20)

        Console.WriteLine("Drawing the Graphic in current view")
        TCADGraphic.Draw()

        Console.WriteLine("Adding Graphic to selection collection")
        TCADGraphic.Select()

        Console.WriteLine("Finished")
        Console.ReadLine()

        TCADDrawing.Close(False)

    End Sub

End Module

Logged