Solidworks二次开发--装配体中插入零部件
在往装配体中插入零部件时,我们使用addcomponent 函数。如果需要选定零部件的配置,则需要使用addcomponent4。
先学习下语法:
addcomponent4:
retval = AssemblyDoc.AddComponent4 ( compName, configName, x, y, z)
Input: (BSTR) compName Path name of a loaded part or assembly to add as a component
Input: (BSTR) configName Name of the configuration from which to load the component
Input: (double) x X coordinate of the component center
Input: (double) y Y coordinate of the component center
Input: (double) z Z coordinate of the component center
Output: (LPCOMPONENT2) retval Pointer to the Component2 object
需要注意的是:参数1为文件的全名(包括路径);参数2为文件的配置名称;当函数执行成功购返回一个指向该零件的指针。
于是我们可以如下写一个小程序,用来给