revit无法加载图像路径

发布于 2025-01-23 18:22:42 字数 818 浏览 1 评论 0原文

我试图将临时的内在图形图形放在这样的修订中:

var activeUiDoc = document.Application.ActiveUIDocument;
        var activeDbDoc = activeUiDoc.Document;



        using (var graphicsManager = TemporaryGraphicsManager.GetTemporaryGraphicsManager(activeDbDoc))
        {

            try
            {
                var insertionPoint = activeUiDoc.Selection.PickPoint("Select insertion Point");
                var logoData = new InCanvasControlData(@"C:\Program Files\Autodesk\Revit 2023\uniE1D2.bmp", XYZ.Zero);

                var index = graphicsManager.AddControl(logoData, ElementId.InvalidElementId);
            } catch(Exception ex) 
            {
                return;
            }
        }

但是我“无法从指定的路径加载图像”。错误信息。我尝试了各种不同的路径,错误停留。

Revit 2023 API是否有问题?我可以尝试显示我的图像?

感谢您的帮助。

i try to Place a Temporary In-Canvas Graphic in Revit like this:

var activeUiDoc = document.Application.ActiveUIDocument;
        var activeDbDoc = activeUiDoc.Document;



        using (var graphicsManager = TemporaryGraphicsManager.GetTemporaryGraphicsManager(activeDbDoc))
        {

            try
            {
                var insertionPoint = activeUiDoc.Selection.PickPoint("Select insertion Point");
                var logoData = new InCanvasControlData(@"C:\Program Files\Autodesk\Revit 2023\uniE1D2.bmp", XYZ.Zero);

                var index = graphicsManager.AddControl(logoData, ElementId.InvalidElementId);
            } catch(Exception ex) 
            {
                return;
            }
        }

But i get a "Failed to load the image from specified path." Error message. I have tried various different Paths, the Error stays.

Is there an Issue with the Revit 2023 Api? What can i try to get my image displayed?

Thanks for the help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

青丝拂面 2025-01-30 18:22:42

我们发现.bmp图像必须具有(0,128,128)的背景颜色值。我们的2022年修订图像有所不同。一旦我们更改了颜色值,图像就会成功加载。

We found out that .bmp images must have a Background color value of (0,128,128). Our images for Revit 2022 were somehow different. Once we changed the Color value, the images loaded successfully.

赠意 2025-01-30 18:22:42

您是否试图使用管理权进行修订?默认情况下,修订的过程可能没有必要的权限。

也许在调用incanvascontroldata之前这样确保您可以打开文件?

         using (FileStream fs = new FileStream(filename, FileMode.Open))
        using (Bitmap b = new Bitmap(fs))
            Debug.Assert(new Bitmap(b) != null);

Have you tried to run Revit with admin rights? The process that Revit runs on might not have necessary permissions by default.

Maybe something like this before you call InCanvasControlData to make sure you can open the file?

         using (FileStream fs = new FileStream(filename, FileMode.Open))
        using (Bitmap b = new Bitmap(fs))
            Debug.Assert(new Bitmap(b) != null);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文