Revit Api-具有文件路径纹理的材料

问题描述 投票:0回答:1

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

现在,我正在做些肮脏的修改,在这里我搜索标准的“地球”,并使用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;
    }
textures texture-mapping revit-api revit
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.