Hello,
When importing a revit model with PIXYZ Plugin 3.0.5 many materials do not appear to be assigned.
The objects without a materiaal appear as a solid pink.
I’ve tried:
- reimporting
- using the alternative importers from the debug settings, but when I do this most of the elements are missing. The present elements do have their material assigned in the material slot.
How can I resolve this issue?
Hello @IngeniumNV !
Thanks for your messeage. This could be a bug. Can you please share your file and explain the missing information here?
Thanks for your help improving Pixyz Plugin
Ah,
I wish I could share the file, but it is under an NDA for a new prospect.
Is there any logging I could enable or check instead?
In the Editor log I can see messages of Textures which weren’t found. This is possible, but even without the texture I would expect a material to be applied.
With friendly regards,
Hi @AxelJacquet ,
I believe my pink issue is due to a ‘none’ material being applied to my object, but a none material does not exist in the imported model from PIXYZ 3.0.5.
When compared to PIXYZ 2.0.8
Regards,
Hi @IngeniumNV,
The pink material is the default color displayed by Unity when no material is assigned.
Because your texture failed to be loaded, the material creation is probably broken on the Pixyz SDK side. Leading to the unability to create a correct material, so none is added.
The previous behavior from 2.0.8 is not more correct than the one in 3.0.5, since the material is not matching the one described in your file. At least, having it in pink bring your attention to a particular gameObject that has no correct material assigned.
For your use case, you could write a custom Action, that assign a default material to your meshrender when the material is Null. Then you can add this rule in your importer ruleset. So it’s replacing pink empty mat with yours, when you import a model.
Here is an implementation example of such Custom Action:
#if PIXYZ_PLUGIN_FOR_UNITY
using System.Collections.Generic;
using UnityEngine;
using UnityEditor.PixyzPlugin4Unity.Actions;
// Please ensure your class and your file have the same name
public class SetDefaultMat : ActionInOut<IList<GameObject>, IList<GameObject>>
{
[UserParameter]
public Material defaultMaterial;
public override int Id { get { return 548006311;} }
public override string MenuPathRuleEngine { get { return "Custom/SetDefaultMat"; } }
public override string MenuPathToolbox { get { return "Custom/SetDefaultMat"; } }
public override string Tooltip { get { return "Assign default material";} }
public override string Icon { get { return null ; } }
public override int Priority => 15001;
public override IList<GameObject> Run(IList<GameObject> input)
{
foreach (GameObject go in input)
{
MeshRenderer renderer = go.GetComponent<MeshRenderer>();
if (renderer == null)
{
continue;
}
Material[] materials = renderer.sharedMaterials;
for (int i=0; i< materials.Length; i++)
{
if (materials[i] == null)
{
materials[i] = defaultMaterial;
}
}
renderer.sharedMaterials = materials;
}
return input;
}
}
#endif
cf: How I made the Material Renamer Action showcased in the Webinar
1 Like
@Selim_B , thanks for the feedback.
It seems this issue is indeed a good moment to get to know custom actions
Merging meshes that don’t have metadata and moving them up to the parent object which does have metadata seems also something I would like to figure out.
Nice !
Making your own custom action is the best way to leverage the full potential of Pixyz SDK. I recommend you to take a look at the source code of the Actions: FilterOnMetadata.cs and Merge.cs to get inspiration.
If you struggle, feel free to open a new post on the forum.
Best,
–Selim