社区
Revit,Navisworks建筑施工BIM讨论区
欢迎访问欧特克Revit, Navisworks论坛!分享知识,发帖提问,浏览论坛热帖。
取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

RVT开发QA: 如何通过Revit API来获取构件的图形样式?

1 条回复1
已解决
回复
1 条消息(共 2 条)
JimJia
693 次查看, 1 条回复

RVT开发QA: 如何通过Revit API来获取构件的图形样式?

JimJia
Alumni
Alumni

Q:

我想开发一个插件用来从视图中导出构件的信息到其他的格式,我现在想根据构件所在视图的不同,材质的不同等来获取构件最终的图形样式,因为在某个视图中可能存在这个样式替换的可能,请问有什么办法可以实现吗?


Jim Jia
Autodesk Forge Evangelist
https://forge.autodesk.com
Developer Technical Services
Autodesk Developer Network
Email: Jim.Jia@autodesk.com
0 个赞

RVT开发QA: 如何通过Revit API来获取构件的图形样式?

Q:

我想开发一个插件用来从视图中导出构件的信息到其他的格式,我现在想根据构件所在视图的不同,材质的不同等来获取构件最终的图形样式,因为在某个视图中可能存在这个样式替换的可能,请问有什么办法可以实现吗?


Jim Jia
Autodesk Forge Evangelist
https://forge.autodesk.com
Developer Technical Services
Autodesk Developer Network
Email: Jim.Jia@autodesk.com
1 条回复1
2 条消息(共 2 条)
JimJia
回复: JimJia

JimJia
Alumni
Alumni
已接受的解答

A:

您需要自己通过判断去获取,首先通过类别来获取到图形样式,如何看这个构件在视图中是否被替换了图形样式,如果被替换的话,就获取替换后的图形样式。下面的代码供您参考:

public void GetGraphicsStyleInView(Document doc, View view, Element e)
        {
            /*
             * first get graphics style from element's category, 
             * if override graphics setting setted, get from override
             */
            Color color = null;
            int? lineWeight = null;
            LinePattern linePattern = null;

            //get line weight& color from category
            lineWeight = e.Category.GetLineWeight(GraphicsStyleType.Projection);
            color = e.Category.LineColor;

            ElementId patternId = e.Category.GetLinePatternId(GraphicsStyleType.Projection);
            if(patternId != ElementId.InvalidElementId)
            {
                LinePatternElement patternElement = doc.GetElement(patternId) as LinePatternElement;
                if (patternElement != null)
                    linePattern = patternElement.GetLinePattern();
            }

            //if element has override, then get from override 
            OverrideGraphicSettings overrideGraphicSettings = doc.ActiveView.GetElementOverrides(e.Id);
            if (null != overrideGraphicSettings)
            {
                if(overrideGraphicSettings.CutLineColor.IsValid)
                    color = overrideGraphicSettings.CutLineColor;
                if(overrideGraphicSettings.CutLineWeight > 0)
                    lineWeight = overrideGraphicSettings.CutLineWeight;
                if (overrideGraphicSettings.CutLinePatternId != ElementId.InvalidElementId)
                {
                    LinePatternElement patternElement = doc.GetElement(overrideGraphicSettings.CutLinePatternId) as LinePatternElement;
                    if (patternElement.GetLinePattern() != null)
                        linePattern = patternElement.GetLinePattern();

                }
            }
        }

Jim Jia
Autodesk Forge Evangelist
https://forge.autodesk.com
Developer Technical Services
Autodesk Developer Network
Email: Jim.Jia@autodesk.com
0 个赞

A:

您需要自己通过判断去获取,首先通过类别来获取到图形样式,如何看这个构件在视图中是否被替换了图形样式,如果被替换的话,就获取替换后的图形样式。下面的代码供您参考:

public void GetGraphicsStyleInView(Document doc, View view, Element e)
        {
            /*
             * first get graphics style from element's category, 
             * if override graphics setting setted, get from override
             */
            Color color = null;
            int? lineWeight = null;
            LinePattern linePattern = null;

            //get line weight& color from category
            lineWeight = e.Category.GetLineWeight(GraphicsStyleType.Projection);
            color = e.Category.LineColor;

            ElementId patternId = e.Category.GetLinePatternId(GraphicsStyleType.Projection);
            if(patternId != ElementId.InvalidElementId)
            {
                LinePatternElement patternElement = doc.GetElement(patternId) as LinePatternElement;
                if (patternElement != null)
                    linePattern = patternElement.GetLinePattern();
            }

            //if element has override, then get from override 
            OverrideGraphicSettings overrideGraphicSettings = doc.ActiveView.GetElementOverrides(e.Id);
            if (null != overrideGraphicSettings)
            {
                if(overrideGraphicSettings.CutLineColor.IsValid)
                    color = overrideGraphicSettings.CutLineColor;
                if(overrideGraphicSettings.CutLineWeight > 0)
                    lineWeight = overrideGraphicSettings.CutLineWeight;
                if (overrideGraphicSettings.CutLinePatternId != ElementId.InvalidElementId)
                {
                    LinePatternElement patternElement = doc.GetElement(overrideGraphicSettings.CutLinePatternId) as LinePatternElement;
                    if (patternElement.GetLinePattern() != null)
                        linePattern = patternElement.GetLinePattern();

                }
            }
        }

Jim Jia
Autodesk Forge Evangelist
https://forge.autodesk.com
Developer Technical Services
Autodesk Developer Network
Email: Jim.Jia@autodesk.com

找不到想要的内容?向社区提问或分享您的知识。

到论坛发帖  

”