Have a look at this wrapper for sceneKit. There are plenty of examples, too. Though I made no regression tests lately it should still work, or at least help with understanding the bridging.
Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Posts made by pulbrich
-
RE: 3D rotations in a UImage
-
RE: If, like me, your iDevice is too old for ARKit...
@vignesh : if you want to use SceneKit in a more convenient way, there is a Pythonista wrapper with plenty of examples here:
-
RE: Comment/Uncomment block of lines
@Ivan_OE I didn’t write this code, only use it. But I am happy if it helped.
-
RE: Getting 'set' to print
In your original code move the first closing bracket “)” to the end of the line, the idea being than in python 3.x the print statement needs the arguments in brackets, i.e.
print(“something”)
print ('All scanned codes:\n' + '\n'.join(found_codes) )
should work.
(The original code was ok in python 2.x)
-
RE: Function at end of variable (Don't really know how to sum up this question)
You can subclass str and insert your method in the subclass definition. As long as you use your subclass to create your “string” instances the new method would work. Not for literals though. E.g.,
class funny_string(str): def clean(data): while data.startswith(' '): data = data[1:] while data.endswith(' '): data = data[:-1] return data my_string = funny_string(“ look at this! “) print(my_string.clean()) #### works print(“ huh? “.clean()) #### doesn’t work
-
RE: Regex and numpy question
Then you can use re, which is the Pythonista supplied regex module.
-
RE: Regex and numpy question
If I run
import re print(re)
I get
<module 're' from '/var/containers/Bundle/Application/7F183C05-845F-47C3-93D3-533E30766BBB/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/re.py'>
which is what it should be. Could you try these two lines of code and show the console output?
-
RE: Regex and numpy question
Try
import re
You cannot upgrade numpy, the available version is part of the Pythonista app, not user upgradable.
-
RE: ui.ImageView contents not cropping to View bounds
It’s a uiView property, supposed to regulate the behavior of a view’s subviews.
Instance Property clipsToBounds A Boolean value that determines whether subviews are confined to the bounds of the view.
-
RE: interactive animation based on orientation data of IMU
@ProgrammingGo if you ever need to penetrate the domain of various coordinate system representations (angles included) I recommend you look at Pyrr
-
RE: interactive animation based on orientation data of IMU
@cvp you don’t need a separate thread with all the overhead to update the scene objects. There is the scene renderer delegate (can be the same class instance as your main), which has an 'update' method to take care of exactly these type of tasks.
-
RE: interactive animation based on orientation data of IMU
@cvp this is what you meant? 😉
from objc_util import * import ui from math import pi import sceneKit as scn @on_main_thread def demo(): global bt,i_bt main_view = ui.View() w, h = ui.get_screen_size() main_view.frame = (0,0,w,h) main_view.name = 'SceneKit IMU' main_view.background_color = 'white' b = ui.ButtonItem() b.title = 'simul bt' i_bt = 0 bt = [ (pi/2,pi/3,pi/4), (pi/3,pi/3,pi/4), (pi/2,pi/5,pi/4), (pi/2,pi/3,pi/8) ] @on_main_thread def b_action(sender): global i_bt,bt # EulerAngles is a SCNVector3 # The order of components in this vector matches the axes of rotation: # Pitch (the x component) is the rotation about the node’s x-axis. # Yaw (the y component) is the rotation about the node’s y-axis. # Roll (the z component) is the rotation about the node’s z-axis. x = bt[i_bt] geometry_node.setEulerAngles(x) i_bt += 1 if i_bt == len(bt): i_bt = 0 b.action = b_action main_view.right_button_items = (b,) scene_view = scn.View(main_view.frame, superView=main_view) scene_view.autoresizingMask = (scn.ViewAutoresizing.FlexibleHeight, scn.ViewAutoresizing.FlexibleRightMargin) scene_view.allowsCameraControl = True scene_view.backgroundColor = 'white' scene = scn.Scene() scene_view.scene = scene root_node = scene.rootNode camera = scn.Camera() camera_node = scn.Node() camera_node.camera = camera camera_node.position = (-30,30,30) root_node.addChildNode(camera_node) geometry = scn.Box(10, 10, 10, 0) geometry_node = scn.Node.nodeWithGeometry(geometry) root_node.addChildNode(geometry_node) Materials = [] colors = ['red','blue','green','yellow','orange','pink'] for i in range(0,6): Material = scn.Material() Material.contents = colors[i] Materials.append(Material) geometry.materials = Materials # Add a constraint to the camera to keep it pointing to the target geometry constraint = scn.LookAtConstraint.lookAtConstraintWithTarget(geometry_node) constraint.gimbalLockEnabled = True camera_node.constraints = [constraint] light_node = scn.Node() light_node.position = (30, 0, -30) light = scn.Light() #light.setType_('spot') light.type = scn.LightTypeProbe #light.setType_('directional') light.castsShadow = True light.color = 'white' light_node.light = light root_node.addChildNode(light_node) main_view.present('fullscreen') demo()
-
RE: No update?
@cvp said:
I had remarked similar moustaches but I didn't dare post something
I guess it just comes with experience.
-
RE: List = dictionary
Or, if readability is not much of a concern:
dict = {'12345':6, '01928':7} list = [1, 2, 3] found = [k for k in dict.keys() if set([int(aK) for aK in k]) >= set(list)] print(found)
-
RE: List = dictionary
dict = {'12345':6, '01928':7} list = [1, 2, 3] set_list = set(list) found = [] for k in dict.keys(): if set([int(aK) for aK in k]) >= set_list: found.append(k) print(found)