Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PolymeshTopology UVs

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
ebarMLN7G
1785 Views, 4 Replies

PolymeshTopology UVs

I am working on a geometry exporter from Revit and am having some issues with UV values. I can successfully retrieve the UV values from PolymeshTopology nodes, but the generated renderings don't look quite right. Here are two assumptions that i have made (I think one or both of them are wrong)

 

1- I loop through PolymeshFacet instances for each PolymeshTopology and get the points and their associated UV:

 

XYZ p1 =  polymeshTopology.GetPoint(polymeshFacet.V1);

UV p1Uv = polymeshTopology.GetUV(polymeshFacet.V1);

 

My first question: Is that the correct way of retrieving a point and the associated UV?

 

Second questions: The final UV values need to be converted to a [0.00, 100] scale, but the values out of Revit can be larger than 1, so I basically just use the fraction part and ignore the rest, is that the correct conversion?

4 REPLIES 4
Message 2 of 5
JimJia
in reply to: ebarMLN7G

Dear Ehsan Barekati,

 

Can you help to clarify the rendering issue? what's wrong with the rendering?

 

Besides, you may refer to these pages, hope it's helpful:

https://thebuildingcoder.typepad.com/blog/2013/07/adn-mesh-data-custom-exporter-to-json.html

https://thebuildingcoder.typepad.com/blog/2016/07/exporting-rvt-bims-to-webgl-and-forge.html

 

 


Jim Jia
Autodesk Forge Evangelist
https://forge.autodesk.com
Developer Technical Services
Autodesk Developer Network
Email: Jim.Jia@autodesk.com
Message 3 of 5
ebarMLN7G
in reply to: JimJia

Hi Jim,

 

Yeah absolutely, I am attaching two images, one that's from my rendering, and the other one directly from Revit. They should ideally look similar, but as you can see the UV mapping on the exported one is not correct. revit.PNGusd.PNG

 

The rendering system that I am exporting to, uses a  [0.00, 100] scale, where the bottom left pixel of the texture image has a (0,0) UV and the top right has (1,1). So my question is how can I translate the UV values in Revit to that scale? 

Message 4 of 5
ebarMLN7G
in reply to: ebarMLN7G

Here is a more detailed example:

 

I created a simple wall in Revit and added a simple wall material to it:

 

revit.PNG

The Texture is a 219*256 png:

 

Brick_Non_Uniform_Running_Burgundy.png

 

Here is the UV values that I get when exporting the model using Custom Export:

 

U: 0 V: 0
U: 8.5 V: 3.34431
U: 8.5 V: 0
U: 8.5 V: 3.34431
U: 0 V: 0
U: -8.5 V: 3.34431
U: -8.5 V: 0
U: 0 V: 3.34431
U: 0 V: 0
U: 0 V: 3.34431
U: 8.5 V: 0.333333
U: 1.06643e-15 V: 0.333333
U: 8.5 V: -0.333333
U: -1.06643e-15 V: -0.333333
U: 8.5 V: -0.333333
U: 1.06643e-15 V: 0.333333
U: -0.333333 V: 3.34431
U: -0.333333 V: 0
U: 0.333333 V: 0
U: 0.333333 V: 0
U: 0.333333 V: 3.34431
U: -0.333333 V: 3.34431
U: 8.5 V: -0.333333
U: 8.5 V: 0.333333
U: 8.5 V: 0.333333
U: 0 V: 0.333333
U: 1.77636e-15 V: -0.333333
U: 0.333333 V: 0
U: 0.333333 V: 3.34431
U: -0.333333 V: 3.34431
U: -0.333333 V: 3.34431
U: -0.333333 V: 0
U: 0.333333 V: 0
U: 0.0131127 V: -0.0100617
U: 0.0104167 V: -4.68375e-17
U: 0.0104167 V: -4.68375e-17
U: 0.015625 V: -0.0090211
U: 0.0177824 V: -0.0073657
U: 0.015625 V: -0.0090211
U: 0.0104167 V: -4.68375e-17
U: 0.0131127 V: -0.0100617
U: 0.0204784 V: -0.00269603
U: 0.0104167 V: -4.68375e-17
U: 0.0194378 V: -0.00520833
U: 0.0208333 V: -4.68375e-17
U: 0.0104167 V: -4.68375e-17
U: 0.0204784 V: -0.00269603
U: 0.0194378 V: -0.00520833
U: 0.0104167 V: -4.68375e-17
U: 0.0177824 V: -0.0073657
U: 0.000354939 V: 0.00269603
U: 0.0104167 V: 3.14465e-17
U: 0.0104167 V: 3.14465e-17
U: 0.00305097 V: 0.0073657
U: 0.00139557 V: 0.00520833
U: 0.0104167 V: 3.14465e-17
U: 0.000354939 V: 0.00269603
U: -1.9082e-17 V: 3.14465e-17
U: 0.00520833 V: 0.0090211
U: 0.0104167 V: 3.14465e-17
U: 0.00772063 V: 0.0100617
U: 0.0104167 V: 3.14465e-17
U: 0.00520833 V: 0.0090211
U: 0.00305097 V: 0.0073657
U: 0.0104167 V: 0.0104167
U: 0.00772063 V: 0.0100617
U: 0.0104167 V: 3.14465e-17
U: 0.0131127 V: -0.0100617
U: 0.0104167 V: -4.68375e-17
U: 0.0104167 V: -4.68375e-17
U: 0.015625 V: -0.0090211
U: 0.0177824 V: -0.0073657
U: 0.015625 V: -0.0090211
U: 0.0104167 V: -4.68375e-17
U: 0.0131127 V: -0.0100617
U: 0.0204784 V: -0.00269603
U: 0.0104167 V: -4.68375e-17
U: 0.0194378 V: -0.00520833
U: 0.0208333 V: -4.68375e-17
U: 0.0104167 V: -4.68375e-17
U: 0.0204784 V: -0.00269603
U: 0.0194378 V: -0.00520833
U: 0.0104167 V: -4.68375e-17
U: 0.0177824 V: -0.0073657
U: 0.000354939 V: 0.00269603
U: 0.0104167 V: 3.14465e-17
U: 0.0104167 V: 3.14465e-17
U: 0.00305097 V: 0.0073657
U: 0.00139557 V: 0.00520833
U: 0.0104167 V: 3.14465e-17
U: 0.000354939 V: 0.00269603
U: -1.9082e-17 V: 3.14465e-17
U: 0.00520833 V: 0.0090211
U: 0.0104167 V: 3.14465e-17
U: 0.00772063 V: 0.0100617
U: 0.0104167 V: 3.14465e-17
U: 0.00520833 V: 0.0090211
U: 0.00305097 V: 0.0073657
U: 0.0104167 V: 0.0104167
U: 0.00772063 V: 0.0100617
U: 0.0104167 V: 3.14465e-17

 

As you can see, the values are in a range from -8.5 to 8.5, how would each UV map to a pixel on the texture PNG? 

Message 5 of 5
JimJia
in reply to: ebarMLN7G

Dear Ehsan Barekati,

 

>>> Is that the correct way of retrieving a point and the associated UV?
Yes, your way is correct. But note that one vertex contains only one uv, so the vertex in several facets has the same uv value. This is the reason why the uv value may be in a big range.

 

>>> The final UV values need to be converted to a [0.00, 100] scale, but the values out of Revit can be larger than 1, so I basically just use the fraction part and ignore the rest, is that the correct conversion?
The UV value has strong connection with image mapping (you should find this via Asset API). The Real World Scale and Real World Offset will affect why UV value mapping to the real picture, the scale value defines the UV unit, and the offset value defines the UV offset.

 

>>> how would each UV map to a pixel on the texture PNG?
As I mentioned above, the Real World Scale and Real World Offset will affect  UV value mapping to the real picture. For example, the UV value is (1, 1), the X scale and y scale define the real length (of data 1) in picture mapping, and the offset define the offset for UV value (0,0) also.

 

 


Jim Jia
Autodesk Forge Evangelist
https://forge.autodesk.com
Developer Technical Services
Autodesk Developer Network
Email: Jim.Jia@autodesk.com

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Customer Advisory Groups


Rail Community