Hi
I have an issue where I have coded a Revit plugin which renders a scene - and calculates the UV coordinates for each vertex. Unfortunately there are a number of situations where UV mapping is wrong - even with planar mapping.
For example, the attached image images shows the results from UV mapping (on the right), verses the "Realistic" viewport setting.
As you can see, the horizontal surface is uncorrectly mapped. MR does not have this issue.
The code to calculate the UV is:
foreach (Face face in solid.Faces) { PlanarFace planarFace = face as PlanarFace; CylindricalFace cylindricalFace = face as CylindricalFace; ConicalFace conicalFace = face as ConicalFace; RevolvedFace revolvedFace = face as RevolvedFace; HermiteFace hermiteFace = face as HermiteFace; RuledFace ruledFace = face as RuledFace; for (int v = 0; v < 3; ++v) { XYZ pointXYZ = triangle.get_Vertex(v); IntersectionResult ir = face.Project(pointXYZ); // Calculate the UV's if the face is planar if (planarFace != null) { if (ir != null) { m_Uvws[uvIndex].U = ir.UVPoint.U; m_Uvws[uvIndex].V = ir.UVPoint.V; } } else if (cylindricalFace != null) { if (ir != null) { ....
So my question is, how can I get correct UV's?
(EDIT: I have invested a significant amount of time trying to implement the approach outlined in http://thebuildingcoder.typepad.com/blog/2010/02/texture-data-uv-coordinates-and-fbx.html and it is simply not viable. It is not possible to match the UV's indexs from the FBX with the vertex indexs obtained via the Revit API. Also, FBX assigns each polygon to a RenderAppearance, rather than a Revit Material - so it is not possible to determine what the material is for a given polygon in the FBX.]
Thanks in advance.
Dear Pfk,
Very sorry, the answer is no.
Best regards,
Jeremy
Dear Pfk,
You will be happy to har that I have an update to my previous answer, and the new reply is yes.
One cannot get accurate UV texture mapping via the regular Revit geometry API.
However, correct UVs can be got from the CustomExporter via an ExportContext in Revit 2014 (a.k.a. Visualization API). The OnPolymesh callback of the context receives PolymeshTopology objects that have UVs for each mesh.
The CustomExporter should be used for most (if not all) export and render external applications.
I hope this helps.
Please let me know how you end up making use of this! Thank you!
Best regards
Jeremy
Dear Paul,
I wish you the best of luck with that and look forward to hearing how it goes for you.
I hear that the UVs are obtained for polymeshes in the exporter context.
Best regards,
Jeremy
I have now implemented the solution proposed in the blog entry and can confirm that it works extremely well. Thank you! My only criticism is that it still doesn't allow obtaining texturemap named assigned to materials in the OnMaterial method. I also noticed that the ArchVision RPC (cutout geometry) props do not get sent to ExportContext. But still a huge step forward.
Thanks again.
Paul
Hello Paul,
Thank you for making progress and reporting on it. 🙂 It seems the Custom Exporter is the right tool for you to utilize. I am sorry about the textures and RPCs. However we are under rather strict copyright obligations and we are not allowed to export data for RPCs in any of our export formats, including custom exports. As for the textures, although there are no such strict restrictions, the entire material component is – technically – not part of Revit code and its internal API does not allow us to acquire texture paths, at least not easily (as far as I know). Hopefully, the material component keeps on improving going forward allowing us expanding the functionality of custom exporters in future releases of the Revit API.
Thank you
Arnošt Löbel
Autodesk Revit R&D
Here is a summary of these results:
http://thebuildingcoder.typepad.com/blog/2013/07/texture-bitmap-and-uv-coordinates.html
Cheers, Jeremy.
I never knew that exporting RPC may violate copyrights.
Yes, using custom export mechanism, there is not way of exporting RPC items like trees.
But some one told me to support RPC and I implemented by own mechanism to export RPC items and they showed up correctly in the final display on the web.
Does it violate any kind of copyright ?
Subir Kumar Dutta
hello Paul,
The texture UV coordinates which I obtained from the CustomExporter(IExportContext::OnPolymesh) directly is larger than UV's in Revit software. Did you know why and How can I obtain the correct UV's?
Thanks.
African
@pfkwrote:I have now implemented the solution proposed in the blog entry and can confirm that it works extremely well. Thank you! My only criticism is that it still doesn't allow obtaining texturemap named assigned to materials in the OnMaterial method. I also noticed that the ArchVision RPC (cutout geometry) props do not get sent to ExportContext. But still a huge step forward.
Thanks again.
Paul
@pfkwrote:I have now implemented the solution proposed in the blog entry and can confirm that it works extremely well. Thank you! My only criticism is that it still doesn't allow obtaining texturemap named assigned to materials in the OnMaterial method. I also noticed that the ArchVision RPC (cutout geometry) props do not get sent to ExportContext. But still a huge step forward.
Thanks again.
Paul
Hi,
just my 50 cent...
It seems that the factor is about three point something.
May it be that there is a unit conversion problem, meters versus feet?
Revitalizer
Hello Revitalizer,
Thank you for your reply. I have tried to unify the vertices and UV's in feet, but it still does not correct. is there something like transformation for UV's?
Thanks.
Hello we are stuck on the visualization of rpc. Which mechanism did you implement to get mesh data for RPC trees and other elements.
Hi there,
RPC are not supported now, just the geometry, not the textures. As developers, we cannot add this functionality for the moment as it's limited by Autodesk restrictions.
Hope I was able to answer your question.
Cheers,
Nathan
Can't find what you're looking for? Ask the community or share your knowledge.