Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Gorgious56/b6f20d3738740143d21da11f3302a40b to your computer and use it in GitHub Desktop.
Save Gorgious56/b6f20d3738740143d21da11f3302a40b to your computer and use it in GitHub Desktop.
import bpy
"""
C poll method :
RegionView3D *CTX_wm_region_view3d(const bContext *C)
{
ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
if (area && area->spacetype == SPACE_VIEW3D) {
if (region && region->regiontype == RGN_TYPE_WINDOW) {
return region->regiondata;
}
}
return NULL;
}
"""
area = next(a for a in bpy.context.screen.areas if a.type == "VIEW_3D")
region = next(r for r in area.regions if r.type == "WINDOW")
data = region.data
if data.use_clip_planes:
data.use_clip_planes = False
else:
bpy.ops.view3d.clip_border({"area":area, "region":region})
data.clip_planes = [
(-0.2558829188346863, -0.33408862352371216, 0.9071430563926697, 0.967681884765625),
(0.8109838962554932, -0.584916353225708, 0.013345977291464806, 2.1694836616516113),
(0.2558809816837311, 0.334089994430542, -0.9071432948112488, 2.9036407470703125),
(-0.8109854459762573, 0.5849142670631409, -0.01334015466272831, 1.093400001525879),
(0.8704013824462891, 0.8216468691825867, 0.9209474921226501, 0.6165103316307068),
(0.8704013824462891, 0.8216468691825867, 0.9209474921226501, 0.6165103316307068)
]
data.update()
region.tag_redraw()
[a.tag_redraw() for a in bpy.context.screen.areas]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment