-
|
Dear all, I am trying to derive a PointOnSurface object from a tin or surface and run into trouble. The last line throws. Hints welcome Seb # Select TIN
es = Ed.Editor.entSel("\nSelect TIN: ", Cv.CvDbTinSurface.desc())
if es[0] != Ed.PromptStatus.eOk:
raise RuntimeError("Yeet! {}: ".format(es[0]))
tin_ids = [es[1]]
# Convert tin to surface
tin = Cv.CvDbTinSurface(tin_ids[0])
sbmesh = tin.subDMesh()
surface = sbmesh.convertToSurface(False, False)
# Create PointOnSurface object and set surface
ptos = Ge.PointOnSurface()
ptos.setSurface(surface) |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
|
Ah Db.Surface VS Ge.Surface, I don’t think there’s a direct conversion. Maybe using Brep? import traceback
from pyrx import Ap, Br, Db, Ed, Ge, Cv
def get_ge_surfaces_from_db_surface(db_surface):
ge_surfaces = []
brep = Br.Brep(db_surface)
traverser = Br.FaceTraverser(brep)
for face in traverser.getFaces():
ge_surf = face.getSurface()
ge_surfaces.append(ge_surf)
return ge_surfaces
@Ap.Command()
def doit():
try:
ps, id, _ = Ed.Editor.entSel("\nSelect TIN: ",Cv.CvDbTinSurface.desc())
if ps != Ed.PromptStatus.eOk:
raise RuntimeError("Yeet! {}: ".format(ps))
tin = Cv.CvDbTinSurface(id)
sbmesh = tin.subDMesh()
surface = sbmesh.convertToSurface(False, False)
for ges in get_ge_surfaces_from_db_surface(surface):
ptos = Ge.PointOnSurface(ges)
print(ptos.point3d())
except Exception:
traceback.print_exc() |
Beta Was this translation helpful? Give feedback.
-
|
For a known point located on a tin object I did as follow finding the normal vector. tri = tin.findTinTrianglesAt(pt)
if len(tri):
quit
ctri = tri[0]
face = Db.Face(ctri.locationAt(0), ctri.locationAt(1), ctri.locationAt(2))
plane = face.getPlane()
vec = plane.normal()or as mistral puts it: if tri := tin.findTinTrianglesAt(pt):
ctri = tri[0]
face = Db.Face(*(ctri.locationAt(i) for i in range(3)))
plane = face.getPlane()
vec = plane.normal() |
Beta Was this translation helpful? Give feedback.
-
|
I added to CvTinTriangle |
Beta Was this translation helpful? Give feedback.
Ah Db.Surface VS Ge.Surface, I don’t think there’s a direct conversion. Maybe using Brep?