How to use the graphics API to draw objects (for example a line)?

Chemsdine CHEMAI
Chemsdine CHEMAI Member, Employee Posts: 201
Photogenic First Comment 5 Likes Solution Developer Community of Practice Member
✭✭✭✭
edited January 15 in Structures

How to use the graphics API to draw objects (for example a line)?

Tagged:

Best Answers

  • Chemsdine CHEMAI
    Chemsdine CHEMAI Member, Employee Posts: 201
    Photogenic First Comment 5 Likes Solution Developer Community of Practice Member
    ✭✭✭✭
    Answer ✓

    One can use the following code :

    graphics = ExtAPI.Graphics
    p1 = graphics.CreateWorldPoint(point1.X, point1.Y, point1.Z)  
    p2 = graphics.CreateWorldPoint(point2.X, point2.Y, point2.Z)  
    line = graphics.Scene.Factory3D.CreatePolyline([p1,p2])
    
  • M
    M Member, Employee Posts: 235
    100 Comments Photogenic 5 Likes Name Dropper
    ✭✭✭✭
    Answer ✓

    You can add some info to make the line visible:

    line.LineWeight = 4
    
    line.Color = 0x00FFFF
    
  • Vishnu
    Vishnu Member, Employee Posts: 219
    Solution Developer Community of Practice Member First Anniversary Name Dropper 100 Comments
    ✭✭✭✭
    Answer ✓

    Just to complete :

    draw_cmd = ExtAPI.Graphics
    p1 = draw_cmd.CreateWorldPoint(0,0,0)
    p2 = draw_cmd.CreateWorldPoint(1000,0,0)
    graphics = ExtAPI.Graphics
    line = graphics.Scene.Factory3D.CreatePolyline([p1,p2])
    line.LineWeight = 4
    line.Color = 0x00FFFF
    

Answers

  • Emil
    Emil Member Posts: 5
    First Comment
    **

    Hello,

    I've tried to used this code to draw a line with both points not in the origing.
    Script is executed but nothing happens.

    I've also tried to create the line and move the coordinate after. But line is created and than it disappears.

    Any idea how to draw a line between two points where position can be defined?

  • Emil
    Emil Member Posts: 5
    First Comment
    **

    Hello,

    I've tried to used this code to draw a line with both points not in the origing.
    Script is executed but nothing happens.

    I've also tried to create the line and move the coordinate after. But line is created and than it disappears.

    Any idea how to draw a line between two points where position can be defined?

  • Emil
    Emil Member Posts: 5
    First Comment
    **

    Hello,

    I've tried to used this code to draw a line with both points not in the origing.
    Script is executed but nothing happens.

    I've also tried to create the line and move the coordinate after. But line is created and than it disappears.

    Any idea how to draw a line between two points where position can be defined?

  • Emil
    Emil Member Posts: 5
    First Comment
    **

    Hello,

    I've tried to used this code to draw a line with both points not in the origing.
    Script is executed but nothing happens.

    I've also tried to create the line and move the coordinate after. But line is created and than it disappears.

    Any idea how to draw a line between two points where position can be defined?

  • Emil
    Emil Member Posts: 5
    First Comment
    **

    Can you please my previous posts and leave only the first one? I had some issues with the website.
    Sorry for the spam!