Hi Thomas,
Thanks for the quick reply - and thanks for the hard work on wrapping occ -
I think it is going to be really useful for my work.
By simple, I was thinking of higher level APIs - like you get with boxes and
cylinders (BRepPrimAPI_MakeBox, BRepPrimAPI_MakeCylinder). I have come
across GC_MakeSegment, but am not sure how to use it - I am still struggling
with the fundamental concepts, especially working with these handles. I was
trying this, but it gives an error:
def line2():
''' Test a line segment'''
display, start_display, add_menu, add_function_to_menu = init_display()
from OCC.gp import gp_Pnt
from OCC.GC import GC_MakeSegment
from OCC.BRepBuilderAPI import BRepBuilderAPI_MakeEdge
p1 = gp_Pnt(0,0,0)
p2 = gp_Pnt(9,9,0)
my_line = GC_MakeSegment(p1, p2).Value()
my_line = BRepBuilderAPI_MakeEdge(my_line)
my_line.Build()
my_line = my_line.Shape()
display.DisplayShape(my_line)
display.View_Iso()
display.FitAll()
start_display()
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Patrick
On 13 May 2010 14:11, Thomas Paviot <[email protected]> wrote:
> 2010/5/13 Patrick Janssen <[email protected]>
>
> I am just getting started, and have been looking at some of the exampls
>> etc... So to draw a line, you would do this:
>>
>> def test5():
>> ''' Test creating a line segment''
>> display, start_display, add_menu, add_function_to_menu =
>> init_display()
>>
>> from OCC.gp import gp_Pnt, gp_Dir
>> from OCC.Geom import Geom_Line
>> from OCC.BRepBuilderAPI import BRepBuilderAPI_MakeEdge
>> p1 = gp_Pnt(0,0,0)
>> line_dir = gp_Dir(1,1,0)
>> my_line = Geom_Line(p1, line_dir).Lin()
>> my_line = BRepBuilderAPI_MakeEdge(my_line)
>> my_line.Build()
>> my_line = my_line.Shape()
>> display.DisplayShape(my_line)
>>
>> display.View_Iso()
>> display.FitAll()
>> start_display()
>>
>>
>> Is there a simpler way?
>> ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
>> Patrick
>>
>>
> Hi Patrick,
>
> In only 14 lines of python code, you manage to display a line in a 3D
> window. I think it's not bad! What do you mean exactly with 'simpler'? Do
> you mean 'less lines'? Whatever the alternative solution could be, you will
> always have to :
> * import python modules/packages,
> * define two points (or a point and a direction),
> * create the line from these two points,
> * send the line to the renderer.
>
> You can use for instance high level wrappers to generate the edges from the
> line:
>
> from OCC.Display.SimpleGui import *
> display, start_display, add_menu, add_function_to_menu = init_display()
> from OCC.gp import gp_Pnt, gp_Dir
> from OCC.Geom import Geom_Line
> from OCC.Utils.Construct import make_edge
>
> p1 = gp_Pnt(0,0,0)
> line_dir = gp_Dir(1,1,0)
> my_line = Geom_Line(p1, line_dir).Lin()
>
> display.DisplayShape(make_edge(my_line))
>
> start_display()
>
> This sample is 11 lines, I would not say it's simpler but smaller.
>
> Thomas
>
> _______________________________________________
> Pythonocc-users mailing list
> [email protected]
> https://mail.gna.org/listinfo/pythonocc-users
>
>
_______________________________________________
Pythonocc-users mailing list
[email protected]
https://mail.gna.org/listinfo/pythonocc-users