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

Open image with python script #23

Closed
mnee15 opened this issue Apr 11, 2023 · 3 comments
Closed

Open image with python script #23

mnee15 opened this issue Apr 11, 2023 · 3 comments

Comments

@mnee15
Copy link

mnee15 commented Apr 11, 2023

Hello, I want to change projection image in python script.

projector = bpy.data.objects['Projector']  
projector.proj_settings.projected_texture = 'custom_texture'  
bpy.ops.projector.image(filepath="image_path")

but projection image does not change.

Do you know the solution?

@Ocupe
Copy link
Owner

Ocupe commented Apr 14, 2023

@mnee15 I am not sure if this will work. 🤔 I never developed the plugin with python scripts in mind. If I can find some time this weekend I will try to find a way.

@richyjunior
Copy link

@mnee15
I had same problem with you. I just solved it by reading the ui.py. It may not be the best solution, but it worked for me.

projector = bpy.data.objects['Projector']  
projector.proj_settings.projected_texture = 'custom_texture'  
node = projector.children[0].data.node_tree.nodes['Image Texture']
image_path="D:\\theLocationOfYourImage\\"
image_filename="name.png"
bpy.data.images.load(image_path+image_filename,check_existing=True)
node.image=bpy.data.images[image_filename]

bpy.context.scene.render.filepath =  "//result.png"
bpy.ops.render.render(use_viewport = True,write_still=True)

Hope this is useful for someone.

@Ocupe
Copy link
Owner

Ocupe commented Sep 10, 2023

@richyjunior Thanks for sharing I linked to your solution from the wiki. 👍
I decided not to spend time working on this, but I'm glad it works with our sample code.

@Ocupe Ocupe closed this as completed Sep 10, 2023
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

3 participants