Jump to content

Getting aspect ratio of a RenderWorks texture image


Recommended Posts

  • Vectorworks, Inc Employee

You will want to do get shader record from the texture resourec, then get texture bitmap from shader record, then get texture bitmap paint node.  Then get object variable with these selectors:
 

const short ovPaintWidthPixels = 530; // Sint32 - Public for VS

const short ovPaintHeightPixels = 531; // Sint32 - Public for VS

 

HTH

Link to comment

@Dave Donley

 

I tried this code with no luck. The first 3 all return handles, but when I try to get the paint node, it returns "None". 

 

Also, the wiki says that vs.GetTexBitPaintNode(textureBitmap) is obsolete. Am I using the right function? 

 

ledtext2 = vs.GetObject(ledimage)
shrec = vs.GetShaderRecord(ledtext2, 1)
texbit = vs.GetTextureBitmap(shrec)
paintnode =vs.GetTexBitPaintNode(texbit)
texwidth = vs.GetObjectVariableInt(paintnode, 530)

vs.Message(f"{ledtext2} / {shrec} / {texbit} / {paintnode} / {texwidth}")

 

Link to comment
  • Vectorworks, Inc Employee

Try this one with get object variable handle on the shader record handle:
 

const short ovShaderRecordImageDefNode = 550; // MCObjectHandle (image node) - Get only

const short ovShaderRecordGrayscaleImageDefNode = 551; // MCObjectHandle (8-bit image node) - Get only

Link to comment
2 hours ago, Pat Stanford said:

I don't see a procedure/function to get what you want.

 

Can't you just get the Begin and End X and Y values (Xb, Xe, Yb, Ye), subtract them to get the pixel size (Xe-Xb, Ye-Yb) and then divide them to get the aspect ratio? 

 

hey Pat! been a while. 

 

I'm going to explore this, but sometimes these textures are on a surface that is faceted or curved. just getting the distance between X1,Y1 and X2,Y2 would always work but its a good direction to look. 

Link to comment

@Dave Donley

 

SUCCESS! The code below got me the pixel dims of the texture. Thank you, sir. 

ledtext2 =  vs.GetObject(ledimage)
shrec = vs.GetShaderRecord(ledtext2, 1)
varhan = vs.GetObjectVariableHandle(shrec, 550)
texwid = vs.GetObjectVariableLongInt(varhan, 534)
texhei = vs.GetObjectVariableLongInt(varhan, 535)

 

 

Can I also get some help with understanding what the units that offsetX:1, offsetY:2 for vs.SetTexMapRealN() use? It seems like it's millimeters, no matter what dim mode I have the document in. Is that true? I'd like to use a dimension field in the PIO to set this, but I'm not sure what units to convert it to. 

 

vs.SetTexMapRealN(last, 3, 0, 1, xoff)
vs.SetTexMapRealN(last, 3, 0, 2, yoff)

 

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