iCAx开思网

标题: CAA: 如何取得external reference? [打印本页]

作者: xyzhu    时间: 2005-3-11 21:52
标题: CAA: 如何取得external reference?
如果在一个PART中引用了另一个PART中的FEATURE, 如何在程序中获得它的原始对象?是用CATIMechanicalImport吗?怎么用呀?
  
谢谢各位!
作者: bright1206    时间: 2005-3-12 09:41
我也遇到这个问题啊,等待各位高手的帮忙。谢谢。
作者: bright1206    时间: 2005-3-17 10:06
怎么没人解答吗?
作者: xyzhu    时间: 2005-3-17 20:52
I found the solution:
  
first, you should go to Tools/Options/Infrastructure/PartInfrastructure, in Tab General, in the first block "external reference", select the first checkbox.
  
Code:
  
CATIPrtPart_var spPart(spSpecOnPart); // you get a part
CATListValCATISpecObject_var spBodies = spPart->GetImportedBodies();
int size = spBodies.Size();
CATUnicodeString extRefs;
for(int i=1; i<=size; i++)
{
  CATIMechanicalImport_var spImport(spBodies);
  CATISpecObject_var spOrig = spImport->GetSelectedFeatureInSourceProduct();
  CATIAlias_var spAlias(spOrig);
  CATUnicodeString strAlias = spAlias->GetAlias();
  
  extRefs += strAlias + ", ";
}
  
With CATIPrtPart::GetImportedBodies() you get the body refernces in the same part, and with CATIMechanicalImport::GetSelectedFeatureInSourceProduct() you get the original ones.
  
Does anybody know, how I can get the mapping of a feature and the external reference, which this feature is using (in the same part)? I mean, I have many features and many external references in a part, how can I find out, which feature uses which external reference? Any idea?
Thank you!
作者: hick    时间: 2005-3-18 14:53
可以参考 powercopy
建议而已,对不对不知道
作者: acoka    时间: 2005-5-24 15:58
很遗憾地告诉你
CATIMechanicalImport在V5R15GA里出问题了,DS说给个代替的interface,但要等到sp2
作者: acoka    时间: 2005-5-24 16:18
和powercopy应该不同
  
powercopy是靠feature的CATIAttrBehavior的GetRequestedBehavior()来实现
  
返回的CATBehaviorSpecs的内容只能是同个part里的spec, 参照的linker也可以的
如果你这这时候用鼠标点了其他part的东西,powercopy命令的FeatureImportAgent会替你做个external reference,然后把它做为输入
作者: acoka    时间: 2005-5-24 16:33
Does anybody know, how I can get the mapping of a feature and the external reference, which this feature is using (in the same part)? I mean, I have many features and many external references in a part, how can I find out, which feature uses which external reference? Any idea?
Thank you!
  
一个一个找的方法比较笨,但肯定可以实现
CATISpecObject->CATISpecAttribute->找里面所有以tk_specobject的特性,然后把它变为CATBaseUnknown,再和external reference比较是不是一样
  
用PathElement或许也可以找到
  
或许有更好的方法,但在公开的interface好像没注意到过有相关的
作者: xyzhu    时间: 2005-5-25 18:46
非常感谢你的回答.
  
还有一个问题:  CATISpecObject 的Attribute有何作用?如果我改变tk_specobject的特性,是不是这个CATISpecObject就指向另一个external reference?
我实际上想用程序实现"替代"的功能,就象右击鼠标后出现的Context Menu 里的那个Replace.
不知道CATIReplace是否能实现这个功能,或者它只是改变CATISpecObjec特性而已?
作者: acoka    时间: 2005-5-25 22:49
Replace的filter是通过CATIAttrBehavior来实现的,
  
CATIReplace的Imp具体有什么用不太明了,按照ds的推荐,GSD的featuer不必自己写,solid的feature要。可以我做过的几个solid的feature好像自己不写也可以,或许默认的CATSpecReplaceExt::Replace(iNameOfRole,ispNewElement,ispOldValue)就够了
  
这2个都是feature的extension imp,所以如果你不自己做catalog建feature了话,一般不会接触到他们
  
自己写想万能的Replace?就用CATIAttrBehavior来取filter好了。举个例子,Pad应该有Skech的tk_specobject,但如果你给它换个CATCkeParm,结果可想而知。所以必须用filter做限制
作者: acoka    时间: 2005-5-26 15:17
调查了一下,搞明白了
  
执行comman创建feature的时候,输入是靠Agent的SetOrderedTypeList来决定鼠标对什么图形特性的东西(比如面还是线)反应,之后可以加个filter进行追加过滤,比如无限大的面不许可
  
同样的功能在做Replace,powercopy,UDF的时候,上头的功能靠feature的CATIReplace,CATIAttrBehavior来实现
SetOrderedTypeOrder对应CATIAttrBehavior的GetRequestedBehavior()
fileter对应CATIReplace的IsElementValidForReplace()
对feature特性的Set在CATIReplace的Replace()实现
  
如果你对你的feature的输入没有特殊filter,那么自己把CATIAttrBehavior给Imp了就好
  
所以你自己的Replace命令可以这么写
1)取得feature的AttrName
2)取得设在个个AttrName里的SpecObject(可以用CATIAlias得到名字)
3)逐个调用CATIReplace,当然这步实际上因为和形状特性有关,有点麻烦
  
不过实在想不出来catia有replace,powercopy的命令可以用,如果你针对个别的feature,各个feature应该有提供对应的Set***()的函数
作者: xyzhu    时间: 2005-5-26 22:12
那么如何使用CATIReplace呢?譬如我有线LINE,它通过点A和点B来确定.现在我要用程序将点B换成点C,是否可用CATIReplace来实现?
如果可以,由谁QueryInterface到CATIReplace呢?是LINE还是点B?
CATIReplace 有三个参数.第一个按DOCU的解释:"name of the attribute whose value is to be replaced",是不是你说的tk_specobject?第二个应该是指点C,第三个是不是点B -- 如果tk_specobject 对应的值是个List的话.
作者: acoka    时间: 2005-5-26 23:49
你有2点做出来的直线的featuere?
那何必废近求远
CATISpecObject_var spLine = /*your line*/
CATIGSMLinePtPt_var spLinePtPt =spLine;
if ( !spLinePtPt ) {
   break;
}
spLinePtPt ->SetScondPonint( 点C );
  
tk_specobject是类型名而已,每个属性都有个CATUnicodeString的名字,你得自己获取feature的所有tk属性的list,




欢迎光临 iCAx开思网 (https://www.icax.org/) Powered by Discuz! X3.3