Jayme McColgan Posted December 2 Share Posted December 2 I'm really struggling to get the aspect ratio of a RenderWorks texture image. any pointers would be appreciated ive tried these plus a few others with no real luck. vs.GetTexBFeatureStart(textureBitmap) vs.GetTexBFeatureEnd(textureBitmap) vs.GetTexBitFeatureSize(textureBitmap) Quote Link to comment
Pat Stanford Posted December 2 Share Posted December 2 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? Quote Link to comment
Vectorworks, Inc Employee Dave Donley Posted December 2 Vectorworks, Inc Employee Share Posted December 2 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 Quote Link to comment
Jayme McColgan Posted December 2 Author Share Posted December 2 @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}") Quote Link to comment
Vectorworks, Inc Employee Dave Donley Posted December 2 Vectorworks, Inc Employee Share Posted December 2 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 Quote Link to comment
Jayme McColgan Posted December 2 Author Share Posted December 2 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. Quote Link to comment
Jayme McColgan Posted December 2 Author Share Posted December 2 @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) 1 Quote Link to comment
Vectorworks, Inc Employee Dave Donley Posted December 2 Vectorworks, Inc Employee Share Posted December 2 Yes I would expect millimeters, those are the internal units Vectorworks uses for coords and dims. Quote Link to comment
Jayme McColgan Posted Thursday at 10:07 PM Author Share Posted Thursday at 10:07 PM @Dave Donley currently I'm using vs.ValidNumStr(vs.GetRField(PIO_handle, recname, "X Offset"))[1] to get the dimension from the field. Is there a function to then turn that into millimeters so i can do the image offset for the texture, since that only wants mm? Quote Link to comment
Pat Stanford Posted Thursday at 11:04 PM Share Posted Thursday at 11:04 PM Returned number * DPI returned by GetUnits * 25.4 (mm/inch)?? PROCEDURE GetUnits( VAR fraction : LONGINT; VAR display : LONGINT; VAR format : INTEGER; VAR upi : REAL; VAR name : STRING; VAR squareName : STRING); Quote Link to comment
Recommended Posts
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.