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

Chemsdine CHEMAI
Chemsdine CHEMAI Member, Employee Posts: 201
100 Likes 100 Comments Second Anniversary Ansys Employee
✭✭✭✭
edited January 2024 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
    100 Likes 100 Comments Second Anniversary Ansys Employee
    ✭✭✭✭
    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: 244
    50 Answers 100 Comments 100 Likes Second Anniversary
    ✭✭✭✭
    Answer ✓

    You can add some info to make the line visible:

    line.LineWeight = 4
    
    line.Color = 0x00FFFF
    
  • Vishnu
    Vishnu Member, Employee Posts: 222
    100 Comments 100 Likes Second Anniversary Name Dropper
    ✭✭✭✭
    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!