Translating Bottle example to OCP

16 views
Skip to first unread message

Dov Grobgeld

unread,
Mar 2, 2024, 1:51:36 AMMar 2
to CadQuery

Hello,

While trying to learn OCCT and the OCP binding, I tried converting the MakeBottle example to pure OCP.

However I got stuck on how to convert a Shape to a Wire:

  aTrsf.SetMirror(xAxis)
  aBRepTrsf = BRepBuilderAPI_Transform (aWire, aTrsf)
  aMirroredShape = aBRepTrsf.Shape()
  aMirroredWire = TopoDS_Wire(aMirroredShape) # Doesn't work!

I tried inspecting the cadquery sources, and saw that it is using a “pycapsule” class Wire_s to do the casting. But I don’t understand where this symbol comes from. There is no such function in TopoDS nor TopoDS_Wire. If I import cadquery I can do the casting through cq.Shape.cast(amirroredShape), but I’m curious how this works?

Thanks in advance!

Jeremy Wright

unread,
Mar 2, 2024, 6:57:18 AMMar 2
to Dov Grobgeld, CadQuery
I believe the "_s" means that it's a static function. It is created as part of the binding generation.

Jeremy

--
cadquery home: https://github.com/CadQuery/cadquery
post issues at https://github.com/CadQuery/cadquery/issues
run it at home at : https://github.com/CadQuery/CQ-editor
---
You received this message because you are subscribed to the Google Groups "CadQuery" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cadquery+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cadquery/CA%2B%2BfsGHZADmxdTMO9mQkbmRUN6xrSAvTjXZqMpNU2m_FjT83ww%40mail.gmail.com.

Dov Grobgeld

unread,
Mar 2, 2024, 12:57:20 PMMar 2
to Jeremy Wright, CadQuery

Thanks Jeremy. I found the answer, and I’ll leave the answer here for posterity.

I was erroneously looking for Wire_s() in OCP.TopoDS, while it is in OCP.TopoDS.TopoDS.

So a pure OCP casting from a OCP.TopoDS.TopoDS_Shape to a OCP.TopoDS.TopoDS_Wire (when the shape represents a wire) looks like the following:

from OCP.TopoDS import TopoDS

aBRepTrsf = BRepBuilderAPI_Transform (aWire, aTrsf);
aMirroredWire = TopoDS.Wire_s(aBRepTrsf.Shape())

Regards,

Reply all
Reply to author
Forward
0 new messages