【问题标题】:Revit Api - Material with Texture from filepathRevit Api - 来自文件路径的纹理材质
【发布时间】:2020-02-13 07:00:56
【问题描述】:

有人知道如何以编程方式创建 Revit 材质并从文件中添加纹理吗?

现在我正在做一些肮脏的 hack,我正在搜索标准的“地球”,并使用 AssetProperty 将路径文件更改为纹理。此解决方案的主要问题是我在项目中没有此材料的情况:P

我只知道如何创建彩色纹理:

    static public Material CreateColorMaterial(Document doc, Color color, string name, bool isTransparency = false)
    {
        SubTransaction createMaterial = new SubTransaction(doc);
        createMaterial.Start();
        //Try to copy an existing material.  If it is not available, create a new one.
        Material materialNew = GetMaterial(name, doc);
        if (materialNew != null)
        {
            createMaterial.Commit();
            return materialNew;
        }

        ElementId idNew = Material.Create(doc, name);
        materialNew = doc.GetElement(idNew) as Material;

        if(isTransparency)
            materialNew.Transparency = 99;

        materialNew.Color = color;
        createMaterial.Commit();

        SubTransaction createPropertySets = new SubTransaction(doc);
        createPropertySets.Start();

        //Create a new structural asset and set properties on it.
        StructuralAsset structuralAsssetColor = new StructuralAsset("ColorStructuralAsset" + name, Autodesk.Revit.DB.StructuralAssetClass.Generic);
        structuralAsssetColor.DampingRatio = .5;

        PropertySetElement pseStructural = PropertySetElement.Create(doc, structuralAsssetColor);

        //Create a new thermal asset and set properties on it.
        ThermalAsset thermalAssetColor = new ThermalAsset("ColorThermalAsset" + name, Autodesk.Revit.DB.ThermalMaterialType.Solid);
        thermalAssetColor.Porosity = 0.1;
        thermalAssetColor.Permeability = 0.2;
        thermalAssetColor.Compressibility = .5;
        thermalAssetColor.ThermalConductivity = .5;

        //Create PropertySets from assets and assign them to the material.
        PropertySetElement pseThermal = PropertySetElement.Create(doc, thermalAssetColor);
        createPropertySets.Commit();
        SubTransaction setPropertySets = new SubTransaction(doc);
        setPropertySets.Start();
        materialNew.SetMaterialAspectByPropertySet(MaterialAspect.Structural, pseStructural.Id);
        materialNew.SetMaterialAspectByPropertySet(MaterialAspect.Thermal, pseThermal.Id);

        setPropertySets.Commit();
        return materialNew;
    }

【问题讨论】:

    标签: c# textures texture-mapping revit-api revit


    【解决方案1】:

    setting material texture path in EditScope 的 Building Coder 解决方案能否解决您的问题?

    【讨论】:

    • 很遗憾没有,因为它只是改变现有材料的纹理:/我正在寻找从头开始创建材料的方法
    • creating a new material and adding new physical and thermal assets 上的 Revit API 论坛帖子解决了这方面的问题,但对纹理没有任何作用...这有帮助吗?
    • 谢谢,我稍后会检查。与此同时,我在后台管理这个加载准备好的模板项目并将其复制到主文档:P 这是一个肮脏的黑客但工作
    • 很高兴听到这个消息!恭喜!以下是有关在 Revit API 中处理材料的其他一些讨论:thebuildingcoder.typepad.com/blog/about-the-author.html#5.5。如果您有解决此问题的新方法,您介意与我们分享吗?谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-04-13
    • 2021-06-24
    • 2021-10-16
    • 1970-01-01
    • 2012-11-15
    • 2014-10-04
    • 2018-03-18
    相关资源
    最近更新 更多