我有以下dxl代码片段, 我想复制具有过滤器F3的对象ID。 : 我不知道我做错了什么它给了我(ID)所有对象。
string Id
int x=0;
int y=0;
Id = o."SourceID"
Filter f0 = hasNoLinks(linkFilterIncoming, "*")
Filter f1=attribute "_TraceTo" == "System"
Filter f2 = attribute "Object Type" == "requirement"
Filter f3 = f1&&f2&&f0
addFilter(m,f3,x,y)
print x ":\t" fullName(module(m)) "\n"
wOutKLHUntraced << Id "\t" fullName(module(m)) "\n"
答案 0 :(得分:1)
首先,您需要在添加过滤器后添加语句filtering on
,以便应用过滤器。然后过滤的对象将是唯一可见的对象。
然后,你设置&#34; Id&#34;在脚本中太早了。在第4行,&#34; o&#34;被设置为
一些对象,我不知道哪一个,但肯定不是结果
你的过滤器。相反,在语句filtering on
之后添加语句
Object o = first m // the first object that is now visible
Id = o."SourceID"
答案 1 :(得分:0)
我的脚本运行良好,但结果不同:因为我在for循环中运行此脚本大约30个模块: 我在设置错误的过滤器吗?
Stream TbdUntraced;
string s
string d
Object o
string trac
int numReqs = 0;
string IdNum
string untraced
int x=0;
int y=0;
int a =0;
for o in m do
{
ensureInLinkedModulesLoaded(o,S_SATISFIES );
s = o."Object Type"
string Id
string Topic
Topic = o."_Topic"
numReqs++;
Filter f0 = hasNoLinks(linkFilterIncoming, "*")
Filter f1 = contains(attribute "_TraceTo", "TBD", false)
Filter f2 = attribute "Object Type" == "requirement"
Filter f3 = attribute "MMS5-Autoliv_Supplier_Status" == "agreed"
Filter f4 = attribute "MMS5-Autoliv_Supplier_Status" == "partly agreed"
Filter f7 = f0&&f2&&(f3||f4)&&f1
addFilter(m,f7,x,y)
filtering on
d = o."MMS5-Autoliv_OEM_Status"
Id = o."SourceID"
Topic = o."_Topic"
print x ":\t" name(module(m)) "\n"
TbdUntraced << Id "\t" Topic "\t"name(module(m)) "\n"
}