Jump to content

Create a texture resource from image in a folder


Recommended Posts

Hi,

I try now to subdivide my question from my previous post - Looking for script to import images as imageprop.

Does anyone have a good approach to create a texture resource from images loaded from a folder.

I found the example script to load images as symbols(https://developer.vectorworks.net/index.php/Python_Sample_Import_Images_as_Symbols), but I can't figure out how to bind them to a renderworks texture. Afterwards the texture could be used on an extruded object or with a image prob.

Cheers

Jonas

 

Link to comment

Hi Jonas,

 

From Vectorworks 2019 and newer it is possible to create a image based texture by using CreateTextureBitmapD (before you had to use a dummy texture...)

#Part 1 - import and convert image
hPaint = vs.ImportImageFile(thePath, 0,0) #Needs to be deleted afterwards
hImage = vs.CreateImageFromPaint(hPaint, 'Just_a_name')

#Part 2 - Create ShaderRecord and convert to TextureBitmap
hShaderRec = vs.CreateShaderRecord(hTexture, 1, 41) #1 = Color image
hTextureBitMap = vs.CreateTextureBitmapD( hShaderRec)

#Part 3 - Connect the image to the TextureBitmap
vs.SetObjectVariableHandle(hTextureBitMap, 528, hImage) #Were the magic happens!

Hope this helps.

🙂

Gelde-Aart

  • Like 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...