Skip to content

Instantly share code, notes, and snippets.

@danielkrajnik
Created November 18, 2021 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielkrajnik/03ae37edbf975f328b2fe8c6cf95320a to your computer and use it in GitHub Desktop.
Save danielkrajnik/03ae37edbf975f328b2fe8c6cf95320a to your computer and use it in GitHub Desktop.
Convert hatches imported from a pdf file into trimmed surfaces
import rhinoscriptsyntax as rs
#get current color
hatchId = rs.GetObject(
"Pick one hatch", filter=65536, preselect=True, select=True,
subobjects=False)
color = rs.ObjectColor(hatchId)
#run macro
macro = """
selcolor invert hide selprev dupborder invert
delete selall planarsrf delete selall join dupborder
invert delete selall planarsrf delete selall group show
"""
rs.Command(macro, echo=False)
#set previous color as a new material
new_objects = rs.SelectedObjects()
for i in new_objects:
material_idx = rs.AddMaterialToObject(i)
rs.MaterialColor(material_idx, color)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment