Jump to content
Carles Olle

How to assign a texture to a 3D object (Solved)

Recommended Posts

This is a question that probably has a simple answer but that, for some reason I cannot manage to get right.

So far I have this code but it does not seem to produce the expected results (the 3D poly-line does not show any texture at all):

 

vs.BeginPoly3D()
vs.Add3DPt((-5, 0, -5))
vs.Add3DPt(( 5, 0, -5))
vs.Add3DPt(( 5, 0,  5))
vs.Add3DPt((-5, 0,  5))
vs.Add3DPt((-5, 0, -5))
vs.EndPoly3D()
image = vs.LNewObj()
textureRef = vs.Name2Index("Test texture")

vs.SetObjExpandTexture(image, 0)
vs.SetTextureRef(image, textureRef, 1)
vs.SetDefaultTexMap(image)

vs.SetTexMapBool(image, 3, 3, True)		# repeat horizontally
vs.SetTexMapBool(image, 3, 4, True)		# repeat vertically
vs.SetTexMapInt(image, 3, 1, 0)			# plane projection
vs.SetTexMapReal(image, 3, 1, 0)		# offset x
vs.SetTexMapReal(image, 3, 2, 0)		# offset y
vs.SetTexMapReal(image, 3, 3, 10)		# scale
vs.SetTexMapReal(image, 3, 4, 0)		# rotation

Why this doesn't work?

Any hint will be appreciated.

 

--Carles

Edited by Carles Olle

Share this post


Link to post

To assign a texture to the 3D object use the vs.SetTextureRefN(obj, textureRef, texPartID, texLayerID), so your script would look like:

 

vs.BeginPoly3D()
vs.Add3DPt((-5, 0, -5))
vs.Add3DPt(( 5, 0, -5))
vs.Add3DPt(( 5, 0,  5))
vs.Add3DPt((-5, 0,  5))
vs.Add3DPt((-5, 0, -5))
vs.EndPoly3D()
image = vs.LNewObj()

textureRef = vs.Name2Index("Test texture")

texPartID = 0
texLayerID = 0
vs.SetTextureRefN(image, textureRef, texPartID, texLayerID)

 In the above the texPartID is the primary and the texLayerID is about the base object (0) or decals(1 and further).

  • Like 1

Share this post


Link to post

Thanks spaghetto for helping!

 

I think one detail is that the texture part for 3D polygons should be 3 (for overall texture part).  HTH

 

  • Like 1

Share this post


Link to post

Dave your right: 3 is overall, but don't know why it also did work with the 0 as texturePart... 

Did a quick backwards test with an extrude and it seems that 3 is overall, 0 are the sides, 4 is the Top and 5 is the Bottom of an extrude.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×