操作iProperties: 学徒服务器和InventorAPI性能对比

Inventor API学习 第一章 Inventor API基本概述 1. 课程目标——Agent API范例——API COM model 如何使用API——How do I access the API 对象模型——The Object Model 对象工具:browser,VBA debug——Object Model tools:Object browser,VBA debug 集合、枚举、接口——Collection、Enumerate、Inheritance 程序——The Application Onject 如何使用 阅读详情

选自http://modthemachine.typepad.com/my_weblog/2010/03/iproperty-performance.html

Here’s some performance data regarding using Inventor and Apprentice to work with iProperties.  I found this interesting and think it will be useful when architecting your programs so you fully understand the advantages and disadvantages of different approaches.

本文中我的同事Brian使用学徒服务器和InventorAPI对iProperties进行操作,发现了一些有趣的结果。

All of the test results shown below are for processing 1000 unique files.

每种测试处理了1000个不同的文件

Test 1 – Open, Edit, Save, Close 
This test opened each of the 1000 files, edited the value of two iProperties, saved the document, and closed it.
测试1 - 打开,修改,保存,关闭

  1. Apprentice – 116 seconds.
    学徒服务器 - 18秒
  2. Inventor (visible document) – 1068 seconds.  This test opened the documents visibly by setting the second argument of the Documents.Open method to True.
    Inventor (界面可见) - 1068秒。该测试显式打开文档
  3. Inventor (invisible document) – 238 seconds.  This is the same as the test above but opens the documents invisibly by setting the second argument of the Documents.Open method to False.
    Inventor (界面不可见) - 238秒。该测试打开文档,但让其不可见(隐式)

The biggest difference is between opening the document visibly or invisibly.  When a document is opened invisibly, Inventor is able to optimize the open and not read all of the file.  Opening a file invisibly is similar to the time it takes in Apprentice, as shown by test 2 below.  However, for test 1 Apprentice is still twice as fast.  Two things account for the extra time spent by Inventor; changing the property value and saving the document.  Changing the value of an iProperty in Inventor is transacted, meaning that you can undo the operation.  Transacting has some overhead which accounts for some of the time.  Apprentice doesn’t have any transaction capabilities so it doesn’t have this overhead.  The other big difference is the save.  To save an iProperty change in Inventor you need to save the entire document using Document.Save.  In Apprentice you can save just the iProperty portion of the document using PropertySets.FlushToFile.

测试中发现,时间上的差别来自打开文档隐式打开文档,Inventor可以以优化的性能打开,但不会读取所有数据。学徒服务器也是隐式打开,但速度更快。这里有两个因素:修改iProperty和保存文档。如果用Inventor API,修改iProperty将会记录到事务,意味着你可以撤销(undo)。所以占用了一定时间。而学徒服务器没有事务。另外的大差别就是保存,Inventor API需要调用Document.Save, 意味着整个文档的保存工作要做一遍。而学徒服务器只需要调用PropertySets.FlushToFile即可。

Test 2 – Open, Read, Close 
This test also operated on all 1000 files by opening a file, reading property values, and closing the document.
测试2 - 打开,读取和关闭

  1. Apprentice – 92.341 seconds
    学徒服务器 - 92.341秒 
  2. Inventor (invisible document) – 100.374 seconds
    Inventor (隐式) - 100.374秒

These numbers show that there isn’t a lot of difference between invisible Inventor and Apprentice when you don’t do anything that’s transacted and you don’t save the document.  This is particularly important for add-in writers to understand since you can’t use Apprentice within an add-in.
可见,如果只是读取,两者差别不大。而我们知道插件不能使用学徒服务器,因此当你的插件程序读取iProperty时,可考虑隐式打开。不要总显式打开。

Test 3 – Open, Close 
This test uses VB.Net to open and close the same 1000 files.  It opens a file, reads the file into memory, and closes the file.  It is a pure VB.Net program and has nothing to do with Inventor.  I wrote this program to help understand how much of the time is spent on general overhead of reading the file and how much time is spent by Inventor or Apprentice actually doing the work they need to do.  As you can see, most of the time used by Apprentice or Inventor is system overhead of opening and reading the file.  Anytime you have to read or write data to a hard drive, performance will be slow.
测试3- 打开,关闭。该测试用VB.Net打开关闭1000个文件,只是读取,什么事都不做。结果如下 77.69秒。可见无论是学徒服务器或Inventor API,读取方式的情况下,打开和关闭是最耗费时间的,一旦文档调入到内存,很多工作做的很快。

  1. VB.Net – 77.69 seconds

Summary 
If you need to write a utility to manipulate iProperties, using Apprentice will allow you to create the fastest program.  However, if you just need to read iProperty data, opening documents invisibly in Inventor is almost as fast and a good alternative.  Remember that Apprentice cannot be used within an add-in.  If you need to do a lot of iProperty processing (writing and saving) through an add-in it might be worth creating a separate exe that uses apprentice that your add-in uses.  You need to be careful that those documents are not currently open in Inventor.

总结:如果你想操作iProperties,显然最佳选择时学徒服务器。如果你只是读取,用Inventor API (隐式打开文档)也是不错的。而且记住学徒服务器无法在插件中使用。如果你的插件某个环节必须要操作大量的文档,可以考虑启动一个EXE程序,在其中使用学徒服务器去做。

Gotcha 
Here’s something to watch out for when doing any timing tests like those above.  The first time I ran a test it was slow and subsequent runs were significantly faster.  For example, when I first ran test 2 with Inventor it took 100 seconds and then running the same test a second time only took 4 seconds.  Even test 3, which doesn’t have anything to do with Inventor went from 77 seconds for the first run down to 0.338 seconds for subsequent runs.  What’s happening is that Windows is caching data in memory in case the data is used again.  This is great if you are reusing data but I think in most workflows where you’re batch reading and updating iProperties this won’t be the case.  To get the times reported above I rebooted between each test to clear memory and force the data to be read from disk.

还有一点。以上的测试,第一次很慢,接着多次测试都会快些。例如测试2,Inventor API 第一次100秒,第二次只用了4秒。甚至测试3, 啥都没做,就从第一次的77秒到第二次的0.338秒。这是因为操作系统缓存了前面的数据,因此第二次访问就快了。因此如果你的流程中有重用数据的阶段,这是个好消息。


 

Inventor SDK入门---API创建零文档类型的Ribbon命令按钮 Inventor SDK入门---API创建零文档类型的Ribbon命令按钮,本文制作一个ZeroDoc环境下的Ribbon命令按钮。 阅读详情

相关推荐

inventor二次开发-课程1-环境搭建及开发资料

文章目录1.为什么要二次开发?2.二次开发的条件3.inventor开发的资料4.inventor开发的那事儿5.开发方式的选择6.开发环境的搭建:7.本课程的核心思路 1.为什么要二次开发? 定制自己所需要的功能,批量的实现重复性的操作。 能用鼠标和键盘交互绘制的图形,二次开发也可以。 2.二次开发的条件 (1)熟悉inventor的基本操作 (2)具备一定的编程基础,在本次课程中需要用到...

qq_43006346的博客 4249

VBA,iLogic,插件中使用学徒服务器

原文地址: http://adndevblog.typepad.com/manufacturing/2016/03/using-apprentice-from-vba-ilogic-or-an-add-in.html 虽然有时不是很理解为何客户想在VBA,iLogic,插件中使用学徒服务器,因为VBA,iLogic或插件都可以直接访问到Inventor API,而且比学徒服务器有更

Gear Up Cloud 1350

【新版】Inventor二次开发学习指南

以前曾写过一篇文章:http://blog.youkuaiyun.com/autodeskinventorapi/article/details/8120770。由于Autodesk University 中国已关闭,文章中很多链接失效,而且有些内容也需要更新。特作废以前那篇文章,另外撰写一篇新的,大部分内容雷同。软件预备Inventor 产品:可从Autodesk官方网站的Inventor产品目录下载试用...

Gear Up Cloud 1万+

不需要Inventor操作iProperties

原文地址: http://modthemachine.typepad.com/my_weblog/2010/03/iproperties-without-inventor-apprentice.html 大家知道,通常安装了Inventor得到的I叫做Inventor API ,拥有全部API功能。而如果只安装Inventor View (免费的),则可以得到Apprentice(学徒服务器)A

Gear Up Cloud 2360

Inventor 2014 API 新功能 (7) 快速装配

其实这个主要是产品增强的方面,API只是提供了对应的开关和状态选项等。 下面简要介绍一下背景:我们知道,打开超大装配在原来可能会遇到性能问题,即打开缓慢。另外,某些时候,用户可能只是做些简单非修改性的操作。性能的缓慢会影响用户体验。这不仅是Inventor的问题,也是所有软件对超大文件修改的普遍现象,尤其Inventor这样的实施图形处理软件。 通常假定在CPU处理速度和内存都够用的情况下,可

Gear Up Cloud 2703

关于Inventor中物理特性更新的API

在Inventor中物理特性在零部件创建完成后,属性不更新,那么需要使用MassProperty的API来实现。 代码如下: Sub updateMassProperties() Dim oDoc As PartDocument Set oDoc = ThisApplication.ActiveDocument '后台调用MassProperty Debug.print(oDoc.ComponentDefinition.MassProperties) End Sub 或者

qq_39300041的博客 1020

关于访问方法和开发语言的选用

访问方法: 总的来说,任何Autodesk产品成熟的API,都包含三种访问方式:插件,独立的EXE和控件程序。 - 插件:是拓展产品能力的方式,其dll依附于宿主程序。这是Inventor API应用程序大量所使用的。甚至包括Autodesk前两年收购的CFDesign,它是基于Inventor的一个复杂高级应用,其中一些模块功能也是插件。在VB6年代,插件可以dll形式和exe形式,exe自

Gear Up Cloud 1240

CAD软件:Autodesk Inventor Aerospace二次开发_InventorAPI基础

InventorAPI是一个基于COM(Component Object Model)的接口,可以使用多种编程语言进行开发,最常用的是C#和VBA(Visual Basic for Applications)。InventorAPI提供了一系列类和方法,用于访问和操作Inventor中的各种对象,如零件、装配体、图纸等。COM接口是Windows操作系统中的一种技术,用于在不同的编程语言和应用程序之间进行通信。

kkchenjj的博客 1142

InventorViewControl.ocx不能用在Inventor进程内使用的折衷办法

InventorViewControl.oc是一个免费的ActiveX控件,可以嵌入在你的程序里用来显示Inventor的文件(可能也包括dwf文件)。但是它采用的是Apprentice的技术,因为Apprentice是不能运行在Inventor进程内的,所以你不能在.dll类型的插件中使用它。解决办法有两种: 第一个解决的办法是使用进程外的(即.exe类型)插件程序来使用这个控件。这个方

CAD定制乐园 1588

Autodesk Inventor API深入学习与实践指南

Autodesk Inventor 是一款广受欢迎的3D CAD设计软件,它为工程和产品设计师提供了一系列强大的工具,用于创建精确的3D模型和数字原型。在现代制造业领域,Inventor是设计流程不可或缺的一环,尤其对于需要精确模拟和分析的复杂零件和装配体。Autodesk Inventor不仅支持标准的CAD绘图和3D建模,还具备有限元分析(FEA)、运动仿真以及管道和电缆布线等高级功能。通过这些功能,设计师可以在真实环境下测试产品的性能和耐久性,从而在实际生产前优化设计。

weixin_31419153的博客 1233

Inventor API应用实例

Inventor API应用实例 以常用型材截面草绘库的建立为例, 简要介绍了以Invento r A P I 为接口, 用V isual Basic6. 0 二次开发Invento r 草绘功能的一般方法

Inventor API: 2018版本开始API是在线帮助文档

原文链接: http://modthemachine.typepad.com/my_weblog/2017/03/inventor-api-help-is-online.html 一直以来,Inventor API的帮助文档都是以文件形式和产品安装(CHM ),而且某几个版本在某个特定路径,某几个又在其它路径。另外,当用户想对比一些版本与版本间差别时,除了连个相邻版本的差别对比,若需要更多版本查

Gear Up Cloud 5979

Autodesk Inventor API学习

本学习资料是有关Autodesk公司的Inventor产品的API的编程和扩展。如果对图型建模有兴趣研究和学习的朋友可以看看。

Inventor API代码性能优化 - 1

好久没写Inventor方面的专题了。最近我们团队专家Brian写了篇很有深度的文章Improving Your Program’s Performance,专门谈到如何对Inventor API代码性能优化。借此机会翻译概要,供给各位参考。 首先,最好对性能有个量化的评估,到底有多慢。可以使用开发语言中的秒表。例如.NET里有StopWatch。 ' Use the .N

Gear Up Cloud 1410

LwIP在国产MCU的落地实践:从协议栈优化到网络稳定性实战

本文详细介绍了LwIP协议栈在国产GD32F407 MCU上的移植与优化实践,涵盖硬件平台选择、驱动适配、协议栈调优和网络稳定性提升策略。通过内存管理优化、实时操作系统集成和性能测试,为工业物联网应用提供高可靠性网络通信解决方案,显著提升数据传输效率和系统稳定性。

m2n3b4v5c6的博客 270

MIPI信号的分析--结合示波器实际测试波形

如果排查的思路对你有帮助,请记住 消雨匆匆 or 大吊工。码字和排查很累,仅此而已 ,硬件不是抄电路,拿烙铁,懂点软件,细致分析,找问题和破案搜集线索是一样的。 部分内容来自于此博客的大神总结: http://www.elecfans.com/news/wangluo/20170323499614.html http://www.elecfans.com/yuanqijian/jieko...

消雨匆匆 4万+

Inventor API: 简单聊聊ReplaceReference , FileSaveAs, OnFileResolution

原文链接  http://adndevblog.typepad.com/manufacturing/2016/03/replacereference-vs-filesaveas-vs-onfileresolution.html 对装配,组件进行重命名,复制,文件丢失或移动后对装配的重新更新,重新引用,是Inventor开发中的一个重要和常用的需求。方法多样,都是为了让装配结构中的部件对

Gear Up Cloud 1611

嵌入式充电协议深度解析:从QC到PD3.1的技术演进与实战应用

本文深入解析了从QC到PD3.1的嵌入式充电协议技术演进与实战应用。通过电压谈判、协议芯片设计、Type-C接口优化等关键技术,详细介绍了快充协议在嵌入式系统中的实现挑战与解决方案,包括兼容性测试、EMC问题处理及空间限制创新设计,为开发者提供了宝贵的实践经验。

weixin_29194817的博客 419

Inventor SDK入门---API设置零件材料

Inventor SDK入门---API设置零件材料

guoll8952的专栏 734

VLA模型(具身智能入门十)

Vision Language Action(VLA)模型VLA模型是机器人领域的“感知-理解-执行”一体化框架,通过Transformer架构融合视觉、语言、动作模态,核心目标是让机器人在自然语言驱动下,自主完成复杂操控任务。其定义的核心在于“跨模态统一”与“具象化行动”——不仅能“看懂”“听懂”,更能“做出正确的动作”,是实现通用机器人智能的关键方向。提供通用序列建模骨架,让视觉、语言、动作能以“序列”形式统一处理;ViT将视觉输入转换为序列特征,提供“看”的能力;LLMs。

weixin_39699362的博客 9924

【国产MCU系列】-GD32F4开发环境搭建(基于Embedded Builder)

GD32F4系列MCU采用Arm® Cortex®-M4内核,处理器主频高达240MHz,可支持算法复杂度更高的嵌入式应用,具备更快速的实时处理能力,并拥有业界领先的大容量存储优势。

视觉与物联智能 3078

关于Inventor api 二次开发 兼容不同版本

项目文件夹下,Autodesk.项目名称.addin 文件。SupportedSoftwareVersionGreaterThan属性对应的版本如下。

qq_45777216的博客 846

SCADA|用KingSCADA实现设备台账的查询功能

以上为用KingSCADA实现设备台账的查询功能,另外还有一些细节功能,比如当点击增加按钮时弹出的信息窗口内的信息希望是在选中的某行信息,只要找到差不多的设备,修改个别参数即可,避免增加时弹出空白页,所有信息都需要填写。以上为实现设备台账查询的最简单实现,实际项目中可能会更复杂,你做过哪些设备台账或相关的功能,有比较好的创意或高难度功能方法,欢迎在留言区评论,或在交流群探讨,互通有无,共同进步。首先完成界面的组态工作,主要是通过查询按钮,查询SQLServer数据库的设备台账数据,然后填充到报表内。

做有价值的事,积累有价值的笔记! 479

Inventor之入门

1.Inventor SDK SDK是开发包的简称,安装产品后就装上了。位置在: Windows XP:     \SDK Windows Vista:  C:\Users\Public\Documents\Autodesk\Inventor \SDK Windows 7:      C:\Users\Public\Documents\Autodesk\Inventor\SDK

u012859921的博客 1080

OpenHarmony深度定制:从系统到模块的全景剖析与自定义模块实战

目标:在中新增一个算法库,让产品可直接调用。关闭不用的 20+ 系统部件,ROM 缩小 50 %;为自家芯片新增专用驱动模块,快速点亮开发板;内将核心算法库以部件形式集成,实现商业闭源。万物互联时代,差异化才是护城河。

m0_67505153的博客 1032

HQChart实战教程54:Renko砖形K线图实现详解

Renko图(砖形图)起源于日本,只关注价格变动而忽略时间和成交量因素: 2.2 算法说明 初始化:使用第一根K线的收盘价创建第一个砖块 变动检测:计算当前价格与最后一个砖块的差值 砖块生成: 当价格变动≥砖块大小时,生成新砖块 当价格变动不足时,更新当前砖块的高低价 方向判断:根据价格变动方向确定砖块颜色 三、完整实现代码 四、Renko图的高级应用 4.1 动态砖块大小调整 4.2 Renko交易策略 三砖反转策略:趋势跟踪策略:本文详细介绍了Renko图的实现原理和在HQChart中的应

QQ_778132974的博客 872
上一篇: 零件库的族添加自定义行
下一篇: 如何拷贝草图图元到另一个草图
autodeskinventorapi
博客等级 码龄14年 313粉丝 164原创
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值