Jump to content
Developer Wiki and Function Reference Links ×

Assign Texture By Name to Object?


Recommended Posts

Hey guys,

 

I've been doing a lot more scripting over the "break" and am running into some new challenges, but ones which I think are easy.  I'm just missing that one little thing.

 

Say I've created an extrude and want to assign an existing texture to it (I'll get into having the script create textures later).  What is the code to just say "Assign texture 'Blue Noise' to the extrude I just created.  Something like the following:

BeginXtrd(0,3);
	Rect(-1,1,1,-1)
EndXtrd;
oh:=LNewObj;
**AssignTexture(oh,'Blue Noise');***

(the part in asterisks is just the idea of what I'm trying to do)

 

I've looked at the function reference guide, and everything I find seems to refer to texture refs using LONGINT.   How can I assign a texture to an object by name?

Link to comment
2 hours ago, Pat Stanford said:

Name2Index should accept the name of the texture and return the Texture Index you can use with SetTextureRefN.

 

That was the ticket!  I knew i needed to find something to change the name to some sort of reference ID.  I just didn't know what t was.  Took a minute to figure out scaling, too.  Then I found the somewhat confusing SetTexMapReal.

 

Thanks!!

  • Like 1
Link to comment
2 hours ago, C. Andrew Dunning said:

Be sure to look into the different SetTexMapRealN and SetTexMapBoolN selectors.  In addition to scaling you can control things like tiling, X&Y offset, rotation, etc.

 

 

I can barely even figure out Vectorworks texturing normally.  I think you need a degree in theoretical mathematics to determine where Vectorworks is going to place a texture's origin and how scaling will affect it.  But, I'll look into these...

 

(I made a post in the general forum about the texturing positioning, but no one replied 😞 )

Edited by SamIWas
Link to comment

Once you get a feel for things adjusting these basic settings isn't all that bad.  For me, the real trick was figuring out when VW is expecting drawing units and when VW is expecting MM.  Below are some code snippets that might help.  As you look @ them, reference the Image Picker for any of the video tools (Landru Design's or VW's) to see what the code is doing.

 

kTexturePartID = 3;  {overall object}
kTextureLayerID = 0;

SetTexMapBoolN (ObjHan,kTexturePartID,kTextureLayerID,1,TRUE);    {initialize}

SetTexMapBoolN (ObjHan,kTexturePartID,kTextureLayerID,3,TRUE);    {tile horizontally}
SetTexMapBoolN (ObjHan,kTexturePartID,kTextureLayerID,4,TRUE);    {tile vertically}

SetTexMapRealN (ObjHan,kTexturePartID,kTextureLayerID,3,(SCALE/100)*WIDTH/GetObjectVariableReal(TEXTUREHANDLE,511));    {set scale w. 100% matching object width} 
SetTexMapRealN (ObjHan,kTexturePartID,kTextureLayerID,1,(WIDTH*(SHIFTHORIZ/100)*(25.4/GetPrefReal(152))));    {set amount of horizontal shift IN MM relative to percentage of object width} 
SetTexMapRealN (ObjHan,kTexturePartID,kTextureLayerID,2,(HEIGHT*(SHIFTVERT/100)*(25.4/GetPrefReal(152))));    {set amount of vertical shift IN MM relative to percentage of object height}

{
'SCALE' is texture scale in terms of percentage.
'WIDTH' is object width in terms of document units.
'HEIGHT' is object height in terms of document units.
'SHIFTHORIZ' is horizontal shift in terms of percentage.
'SHIFTVERT' is vertical shift in terms of percentage.

'GetObjectVariableReal(TEXTUREHANDLE,511)' returns the Texture's width.
'*(25.4/GetPrefReal(152))' translates a dimension in document units to MM.
}

 

 

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...