Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

polyline only vertices ? #106

Closed
mariolino007 opened this issue Jun 15, 2024 · 5 comments
Closed

polyline only vertices ? #106

mariolino007 opened this issue Jun 15, 2024 · 5 comments

Comments

@mariolino007
Copy link

hi tmontaigu
i have a question, in the code example below, i noticed that once the polyline is generated only the vertices are visible for it, can the geometry of the segments joining the various vertices also be generated ?
thank you


import pycc
import cccorelib

CC = pycc.GetInstance()
pc_to_crop = CC.getSelectedEntities()[0]
bbMin, bbMax = cccorelib.CCVector3(), cccorelib.CCVector3()
pc_to_crop.getBoundingBox(bbMin, bbMax)
print(f"Min {bbMin}, Max: {bbMax}")
diag = bbMax - bbMin

bbMin = bbMin + cccorelib.CCVector3(diag.x / 2, 0, 0)

vertices = pycc.ccPointCloud()
vertices.setName("polyline.vertices")
vertices.addPoint(bbMin)
vertices.addPoint(bbMin + cccorelib.CCVector3(0, diag.y / 2, 0))
vertices.addPoint(bbMin + cccorelib.CCVector3(diag.x / 2, diag.y / 2, 0))
vertices.addPoint(bbMin + cccorelib.CCVector3(diag.x / 2, 0, 0))

polyline = pycc.ccPolyline(vertices)
polyline.setClosed(True)

This is important, otherwise the polyline would have a size of 0

polyline.addPointIndex(0, vertices.size())

#To see the crop area
CC.addToDB(vertices)

cropped_ref = pc_to_crop.crop2D(polyline, 2, True)
if cropped_ref is None:
raise RuntimeError("Failed to crop")

if cropped_ref.size() != 0:
cropped = pc_to_crop.partialClone(cropped_ref)
CC.addToDB(cropped)
else:
print("No points fall in crop area")

@tmontaigu
Copy link
Owner

Yes it should be possible, you need to add the polyline to the DB, not the vertices

However there is a bug, and you'll have to wait for #107 before it actually works

@mariolino007
Copy link
Author

thank you, I will wait

@tmontaigu
Copy link
Owner

The plugin installer has been updated

@mariolino007
Copy link
Author

Hi tmontaigu,

I just wanted to express my sincere gratitude for your prompt response and the update to the plugin installer. I have checked, and everything is now working perfectly.

Thank you for your support and for addressing the issue so quickly. Your assistance is greatly appreciated!

Best regards,
Mario

@tmontaigu
Copy link
Owner

Thanks 🤗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants