pythonocc-utils icon indicating copy to clipboard operation
pythonocc-utils copied to clipboard

Error with the edge class

Open chenkianwee opened this issue 8 years ago • 2 comments

Hi I am having issues with the new occutil. Receiving this error when I ran the Edge class project_vertex function. I realise its got to do with the curve handle function. The curve handle is not returning the curve handle.

@property def curve_handle(self): if self._curve_handle is not None and not self.is_dirty: return self._curve_handle else: return None File "C:\Anaconda2\envs\envuo\lib\site-packages\OCCUtils\edge.py", line 324, in project_vertex poc = GeomAPI_ProjectPointOnCurve(pnt_or_vertex, self.curve_handle) File "C:\Anaconda2\envs\envuo\lib\site-packages\OCC\GeomAPI.py", line 1574, in init _GeomAPI.GeomAPI_ProjectPointOnCurve_swiginit(self, _GeomAPI.new_GeomAPI_ProjectPointOnCurve(*args)) ValueError: invalid null reference in method 'new_GeomAPI_ProjectPointOnCurve', argument 2 of type 'Handle_Geom_Curve const &'

I am having issue when I use intersect fucntion of the Intersect class. It should work if the code is face_curve_intersect.Next() instead of next(face_curve_intersect)

File "C:\Anaconda2\envs\envuo\lib\site-packages\OCCUtils\edge.py", line 53, in intersect next(face_curve_intersect) TypeError: BRepIntCurveSurface_Inter object is not an iterator

chenkianwee avatar Jun 29 '16 11:06 chenkianwee

would you be able to make a script to reproduce the problem?

jf--- avatar Jun 29 '16 13:06 jf---

Yup sure here is the code

from OCC.gp import gp_Pnt
from OCC.BRepBuilderAPI import BRepBuilderAPI_MakePolygon, BRepBuilderAPI_MakeFace, BRepBuilderAPI_MakeEdge
from OCCUtils import edge
def make_edge(pypt1, pypt2):
    gp_point1 = gp_Pnt(pypt1[0], pypt1[1], pypt1[2])
    gp_point2 = gp_Pnt(pypt2[0], pypt2[1], pypt2[2])
    make_edge = BRepBuilderAPI_MakeEdge(gp_point1, gp_point2)
    return make_edge.Edge()
def make_polygon(pyptlist):   
    array = []
    for pt in pyptlist:
        array.append(gp_Pnt(pt[0],pt[1],pt[2]))
    poly = BRepBuilderAPI_MakePolygon()
    map(poly.Add, array)
    poly.Build()
    poly.Close()
    wire = poly.Wire()
    occface = BRepBuilderAPI_MakeFace(wire)
    return occface.Face()

#point to be projected
orig_pnt = gp_Pnt(0, 0, 10)
#edge to be projected to
dest_edge = make_edge((50,100,0), (50,20,0))
occutil_edge = edge.Edge(dest_edge)
#project point to edge
u, projpt = occutil_edge.project_vertex(orig_pnt)
#face the edge will intersect with
inter_face = make_polygon(((30,75,0),(60,75,0),(60,75,50),(30,75,50)))
#intersect edge with face
interptlist = occutil_edge.Intersect.intersect(inter_face, 1e-2)

chenkianwee avatar Jun 30 '16 03:06 chenkianwee