Dear Autodesk Development Team,
Wishing you the best in 2023.
Can you help me to solve my issue, please?
There are only two ways to import solids into Revit, using DirectShapes or using FreeFormElements.
But if you want configurable materials applied to your Geometries the suggested way is using FreeFormElements, because DirectShapes can't deal with Material Parameters.
But DirectShapes are the only containers can preserve the parametric space of the faces of your solids, because FreeFormElements have an awkward bug/(maybe feature) and they modify the original UV parametric space used for texturing. FreeFormElements simply unable to hold the directions of UV space and flips the texturing directions. Which is even worse that this behavior depends on the FreeFormElement position/direction.
So when directions of Textures matter and you need configurable materials applied, you are in a big trouble!
No DirectShapes... No FreeFormElements... What else has been remained?
So, my questions are as follows:
- Will you add Material Paramaters to DirectShape? (If yes, when? It is an ancient issue dated back to 2015 by this Forum...)
- Is it a feature or a bug when you flips the directions of texturing in case of FreeFormElement? (I suppose its a bug, because if I rotate the FreeFormElement by just 1 degree around X-Axis, it flips the texture direction again.)
- If it is a bug, will you fix it? (If yes, when?)
- If it is not a bug, can you help with describing at least your algorithm you are using to decide to flip or not to flip the Textures?
- Is there any other solution/workaround you can suggest?
Thank you in advance,
Nandor Csapko
Dear Nandor,
Thank you for your interesting question and useful input.
I am not sure that all your statements are accurate. Please provide proof, if you can.
Here are some articles on direct shapes:
https://thebuildingcoder.typepad.com/blog/about-the-author.html#5.24
Several of them discuss how to define their colour and material. Do they possibly help clarify the situation for you?
If you wish to report anything that you consider a Revit API bug, please supply a minimal reproducible case for that:
https://thebuildingcoder.typepad.com/blog/about-the-author.html#1b
However, please be aware that the Revit API hardly even provides any functionality that is not available in the Revit end user interface, so that would be the primary area in which to request new functionality that is currently unavailable in the product.
Furthermore, if you wish to request new functionality for Revit, you could submit a wish for it to the Revit Idea Station. The Revit Idea Station is currently one of the main driving input forces for Revit API enhancements. The Revit development team looks there. Your comment here in the discussion forum might be over looked. Whenever you require a new or enhanced Revit product or Revit API functionality, the Revit Idea Station is the place to go. Please search there for a corresponding wish list entry for the suggested functionality and add your comments to it, or create a new one, if none already exists:
https://forums.autodesk.com/t5/revit-ideas/idb-p/302
Ensuring that a wish gets as many votes as possible helps underline its importance to you and the rest of the developer community.
Thank you!
Best regards and Happy New Year to you!
Jeremy
Dear Jeremy,
Thank you for your fast response. I am inserting two screenshots here. I have imported the same very simple SAT file containing just a simple planar square Face in its NURBS form (nothing is reversed and nothing is complex) first into a DirectShape and then into a FreeFormElement (via Revit API). And applied the same Textured Material to them. The FreeFormElement's texture mapping flips the texture and doesn't follow the original UV space of the Face as DirectShape do. I am inserting the SAT file source, too. If you rotate the FreeFormElement containing the Face by just one degree around X-axis it flips back the texture the right direction as DirectShape do.
700 31 1 0
35 Open CASCADE 7.5 ACIS SAT interface 4 ACIS 25 Thu Jan 5 09:17:34 2023
1 1e-06 1e-10
-0 body $30 -1 $-1 $1 $-1 $-1 #
-1 lump $-1 -1 $-1 $-1 $2 $0 #
-2 shell $-1 -1 $-1 $-1 $-1 $3 $-1 $1 #
-3 face $-1 -1 $-1 $-1 $4 $2 $-1 $25 forward double out #
-4 loop $-1 -1 $-1 $-1 $5 $3 #
-5 coedge $-1 -1 $-1 $6 $8 $-1 $9 forward $4 $26 #
-6 coedge $-1 -1 $-1 $7 $5 $-1 $10 forward $4 $27 #
-7 coedge $-1 -1 $-1 $8 $6 $-1 $11 forward $4 $28 #
-8 coedge $-1 -1 $-1 $5 $7 $-1 $12 forward $4 $29 #
-9 edge $-1 -1 $-1 $13 0 $14 1 $5 $17 forward @7 unknown #
-10 edge $-1 -1 $-1 $14 1 $15 2 $6 $20 forward @7 unknown #
-11 edge $-1 -1 $-1 $15 2 $16 3 $7 $22 forward @7 unknown #
-12 edge $-1 -1 $-1 $16 3 $13 4 $8 $24 forward @7 unknown #
-13 vertex $-1 -1 $-1 $9 $18 #
-14 vertex $-1 -1 $-1 $9 $19 #
-15 vertex $-1 -1 $-1 $10 $21 #
-16 vertex $-1 -1 $-1 $11 $23 #
-17 intcurve-curve $-1 -1 $-1 forward { exactcur full nubs 1 open 2
0 1 1 1
0 0 10000
10000 0 10000
1.1e-06
null_surface
null_surface
nullbs
nullbs
I I
0
0
0 F 0 F 1
} I I #
-18 point $-1 -1 $-1 0 0 10000 #
-19 point $-1 -1 $-1 10000 0 10000 #
-20 intcurve-curve $-1 -1 $-1 forward { exactcur full nubs 1 open 2
1 1 2 1
10000 0 10000
10000 10000 10000
1.1e-06
null_surface
null_surface
nullbs
nullbs
I I
0
0
0 F 1 F 2
} I I #
-21 point $-1 -1 $-1 10000 10000 10000 #
-22 intcurve-curve $-1 -1 $-1 forward { exactcur full nubs 1 open 2
2 1 3 1
10000 10000 10000
0 10000 10000
1.1e-06
null_surface
null_surface
nullbs
nullbs
I I
0
0
0 F 2 F 3
} I I #
-23 point $-1 -1 $-1 0 10000 10000 #
-24 intcurve-curve $-1 -1 $-1 forward { exactcur full nubs 1 open 2
3 1 4 1
0 10000 10000
0 0 10000
1.1e-06
null_surface
null_surface
nullbs
nullbs
I I
0
0
0 F 3 F 4
} I I #
-25 spline-surface $-1 -1 $-1 forward { exactsur full nubs 1 1 open open none none 2 2
0 1 1 1
0 1 1 1
0 0 10000
10000 0 10000
0 10000 10000
10000 10000 10000
0 0
0
0
0
0
0 F 0 F 1 F 0 F 1
} I I I I #
-26 pcurve $-1 -1 $-1 0 forward { exppc nubs 1 open 2
0 1 1 1
0 0
1 0
1.1e-06
spline forward { ref 4 } I I I I
} 0 0 #
-27 pcurve $-1 -1 $-1 0 forward { exppc nubs 1 open 2
1 1 2 1
1 0
1 1
1.1e-06
spline forward { ref 4 } I I I I
} 0 0 #
-28 pcurve $-1 -1 $-1 0 forward { exppc nubs 1 open 2
2 1 3 1
1 1
0 1
1.1e-06
spline forward { ref 4 } I I I I
} 0 0 #
-29 pcurve $-1 -1 $-1 0 forward { exppc nubs 1 open 2
3 1 4 1
0 1
0 0
1.1e-06
spline forward { ref 4 } I I I I
} 0 0 #
-30 name_attrib-gen-attrib $-1 -1 $-1 $-1 $0 lose lose lose copy @8 COMPOUND #
Dear Jeremy,
I will create a short code snippet next to the screenshots and SAT file I have just posted.
I will send it too soon...
Happy new year and thank you again for your response!
Best regards,
Nandor Csapko
Dear Jeremy,
I'm inserting the code at the and of this post. It can be used to import the sat file previously attached as a DirectShape or as a FreeFormElement.
I have a few more notes to add to this topic:
Importing static geometries into FreeFormElements sounds a little bit overkill for me as nobody wants to transform them, I think using DirectShapes for this purpose would be a more reasonable solution. There are a lot of static objects out there which have to have their materials (sometimes with textures) configurable. A furniture has usually static geometry but it is produced with many different materials. This is why it would be great if you can support configurable materials of DirectShapes. Anyway, it is Autodesk who suggests the using of DirectShapes whenever Texture Mapping matters:
So why don't you support dynamic materials and visibility settings of DirectShapes if these are the only entities in Revit which deal with Texture Mapping in the right way? You can do dynamic materials for FreeFormElements, which means that you could do the same with DirectShapes with no effort, for sure. And it is noted without any offense, that approximately 2750 days spent from the time that you wrote that this request is already logged:
An other hand, FreeFormElements should definitely hold the UV space of the underlying geometries and not to flip it depending on its direction, because it is not too realistic behavior that the texture of a furniture flips when you change the direction of your furniture a little bit.
Best regards,
Nandor Csapko
namespace TextureMappingTest.Revit.Commands
{
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class CommandOpen : IExternalCommand
{
public Result Execute(ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
var doc = commandData.Application.ActiveUIDocument.Document;
if (!doc.IsFamilyDocument)
{
message = "Not a family document";
return Result.Failed;
}
bool importAs_FreeFormElement_InsteadOf_DirectShape = true;
using (var tr = new Transaction(doc))
{
if (tr.Start("Importing SAT") != TransactionStatus.Started)
{
message = "Can't start transaction";
return Result.Failed;
}
try
{
var shapeImporter = new ShapeImporter();
shapeImporter.SetDefaultLengthUnit(ImportUnit.Millimeter);
shapeImporter.InputFormat = ShapeImporterSourceFormat.SAT;
var shapes = shapeImporter.Convert(doc, @"D:\\test.sat");
foreach (var shape in shapes)
{
var solid = shape as Solid;
if (solid != null)
{
if (importAs_FreeFormElement_InsteadOf_DirectShape)
{
var freeFormElement = FreeFormElement.Create(doc, solid);
}
else
{
var directShape = DirectShape.CreateElement(doc, new ElementId(BuiltInCategory.OST_GenericModel));
directShape.ApplicationId = "Application id";
directShape.ApplicationDataId = "Geometry object id";
directShape.SetShape(new GeometryObject[] { solid });
}
}
}
if (TransactionStatus.Committed != tr.Commit())
{
message = "Can't commit transaction";
return Result.Failed;
}
}
catch (Exception ex)
{
message = ex.Message;
tr.RollBack();
return Result.Failed;
}
}
return Result.Succeeded;
}
}
}
Can't find what you're looking for? Ask the community or share your knowledge.