Hello, I need to fetch the attribute values of all the outgoing link in the current module i.e (obtaining the Target Module attribute value). Consider that I am looping like this: Module mod = current Link l Object obj for l in o ->"*" do { //Code here } Sorry for scribbling in wrong way. How do I fetch the Target links's attribute value. I need to fetch attribute value called "Project Rel" Please help me out. KBSri - Wed Jun 18 14:07:00 EDT 2014 |
Re: How to to get the all outgoing links of the current module and fetch the attribute value of the corresponding Target links? Objects have links, not modules. you need "for o in mod" loop. You then need "for l in o ->"*" do" loop. You will likely need to be sure the target modole is open, see the manual about getting the "target" module of the link; get its name, and open it. Then re-look at the links, getting the "target" object. -Louie |
Re: How to to get the all outgoing links of the current module and fetch the attribute value of the corresponding Target links? An alternative to working out what the DXL code should be is to use the DOORS Analysis Wizard tool to create a DXL Layout column that will contain most of the DXL code you will need to display the Target attribute information that you're after - Module Menu: Analysis -> Wizard - configure the Scope-of-Analysis to be a specific Target module which then allows you to select custom defined attributes in that Target Module. Have a look at the DXL code that the Wizard created in the DXL Layout column and either modify the code so that it applies to all target modules or copy, modify and re-use the for\do code fragments in whatever other code you are working on. Just have to make sure that all Target modules at the end of the outgoing links have the same target attribute defined, otherwise you will need to add some checks into the code to avoid errors.
Paul Miller |
Re: How to to get the all outgoing links of the current module and fetch the attribute value of the corresponding Target links? PRM - Wed Jun 18 18:10:38 EDT 2014 An alternative to working out what the DXL code should be is to use the DOORS Analysis Wizard tool to create a DXL Layout column that will contain most of the DXL code you will need to display the Target attribute information that you're after - Module Menu: Analysis -> Wizard - configure the Scope-of-Analysis to be a specific Target module which then allows you to select custom defined attributes in that Target Module. Have a look at the DXL code that the Wizard created in the DXL Layout column and either modify the code so that it applies to all target modules or copy, modify and re-use the for\do code fragments in whatever other code you are working on. Just have to make sure that all Target modules at the end of the outgoing links have the same target attribute defined, otherwise you will need to add some checks into the code to avoid errors.
Paul Miller Sorry unfortunately I am not able to view that code Paul. Please send me if you have. |
Re: How to to get the all outgoing links of the current module and fetch the attribute value of the corresponding Target links? KBSri - Thu Jun 19 01:26:43 EDT 2014 Sorry unfortunately I am not able to view that code Paul. Please send me if you have. I'm not sure if you are saying that you don't know how to view the code, or you are being prevented from viewing the code. I have attached a copy of the DXL Layout code generated by the DXL Layout Wizard for a column that displays the "Object Identifier" attribute, which is the common built-in UID attribute in all formal modules, and an "Importance" attribute which is a custom defined attribute that is specific to Target modules that I have outgoing links to. To view the DXL Layout code created by the Analysis Wizard - RH mouse click over the title of the column that the Wizard created, and select Properties The Edit Column dialogue box will open, the radio buttons will be set to Layout DXL, next to that will be a Browse button, select Browse. A Browse DXL dialogue box will open, select the Current button at the bottom, this will display the DXL code
Paul Miller Attachments DOORSAnalysisWizard-DXL-Layout-Code-Sample.txt |
Re: How to to get the all outgoing links of the current module and fetch the attribute value of the corresponding Target links? Did not try to run the code. [1] If the target module is not open then you cannot get the "target_obj" of the link; get the object after opening the target module. Consider doing this:
[2] At line 41 you check the existence of the attribute. Note that "exists" presumes "the current module". The "current" module changes rather frequently when you open other modules; and it is hopelessly unrealistic to try to predict exactly when that occurs; especially since it changes form DOORS version to version. Far better is to set the "current" module before you EVER use any of the commands that presume the current module:
The lesson here is to keep track of your module handles and use them. You have already kept track of them nicely (modHandle and target_modHandle). [3] I notice you don't check the existence of the other attributes. You can forgo that as follows: To get an attr value; this function does a good job of making sure it exists first.
To set an attr value:
[4] I notice at line 45 you modify a current module's attribute value. Unless that is an attribute-DXL, you can only do that when the module is open Edit, or Shared with the object Locked. [5] Questionable Logic: I think you should get the "Module mLink = module(l)", then check the name, to make sure you are talking about the correct link module. This covers the case "obj" has outging links in more than one link module. [6] Questionable Logic: You are setting "obj" to the value at the end of the link. But if obj has more than one link then the first links will update your ReqID, but be replaced by the last such link. I think you should count links and report an error if there is more than one. [7] check for null strObjectIDfromOriginal. [8] "noError()" at the top can get confusing, especially if you call functions. If there is ANY corresponding "lastError()", then the noError is turned off. Also, you have no paired lastError() but I guess that doesn't matter much, just looks sloppy. [9] move the variable declarations that are local to function "run" into that function. [10] delete(mv) at the bottom of the loop. In fact, remove "mv" since you can get the fullName of (testMod). -Louie |
Re: How to to get the all outgoing links of the current module and fetch the attribute value of the corresponding Target links? BTW, the nice way you layed out your code makes it far easier for other folks (me) to understand it. Consistent indendation and strategic placement of empty lines makes up for your lack of comments. I often argue that this code with its bugs is better than bug-free code that is incomprehensible. -Louie |
Re: How to to get the all outgoing links of the current module and fetch the attribute value of the corresponding Target links? Oh yes. "print" in a loop can be trouble, as it appends this statement to the previous print block, and you run out of memory and DOORS slows to a crawl. The following is vastly better:
-Louie |
Re: How to to get the all outgoing links of the current module and fetch the attribute value of the corresponding Target links? llandale - Fri Jun 20 15:53:15 EDT 2014 Oh yes. "print" in a loop can be trouble, as it appends this statement to the previous print block, and you run out of memory and DOORS slows to a crawl. The following is vastly better:
-Louie Louie! Its you who is making me code better day by day!! I saw your comment and modified the code. I would like to bring to your notice that I want to edit the current module as I need to put the value of "Object ID from Original" to the attribute "Customer-Req ID" attribute. The Customer-Req ID attribute exists only in the current module. I am not able understand your comments numbers [3],[4],[5],[6] and [8]. I have modified according to your comments. My idea is: 1.) Open an module in EXCLUSIVE EDIT mode. 2.) FInd all the outgoing links(Target Links) in current module then copy the attribute value "Object ID from Original" to "Customer-Req ID" attribute in the current module.
|
Re: How to to get the all outgoing links of the current module and fetch the attribute value of the corresponding Target links? KBSri - Mon Jun 23 06:43:53 EDT 2014 Louie! Its you who is making me code better day by day!! I saw your comment and modified the code. I would like to bring to your notice that I want to edit the current module as I need to put the value of "Object ID from Original" to the attribute "Customer-Req ID" attribute. The Customer-Req ID attribute exists only in the current module. I am not able understand your comments numbers [3],[4],[5],[6] and [8]. I have modified according to your comments. My idea is: 1.) Open an module in EXCLUSIVE EDIT mode. 2.) FInd all the outgoing links(Target Links) in current module then copy the attribute value "Object ID from Original" to "Customer-Req ID" attribute in the current module.
I think we already have discussed the proper way about iterating links in a module a dozen times in this forum. You should use a code similar to here: It seems to me (without having read all the discussion), that all you would need to do, is to add one line: o."Customer-Req ID" = probeAttr_ (objTgt, "Original-ID") To the code (and remove the in-link code parts, since you seem not interested in in-links). The advantage of probeAttr_ is it will return an empty string if the attribute does not exist at the target object. Stop messing around with the "current" module in your code, instead always use functions that explicitly take the module to work with as a parameter. So instead of exists attribute "Object ID from Original" you rather use something like:
AttrDef ad = find (modTarget, "Object ID from Original");
if (!null ad) { ... }
Just as a hint for future coding ... Regards, Mathias |
Re: How to to get the all outgoing links of the current module and fetch the attribute value of the corresponding Target links? Mathias Mamsch - Tue Jun 24 15:53:58 EDT 2014 I think we already have discussed the proper way about iterating links in a module a dozen times in this forum. You should use a code similar to here: It seems to me (without having read all the discussion), that all you would need to do, is to add one line: o."Customer-Req ID" = probeAttr_ (objTgt, "Original-ID") To the code (and remove the in-link code parts, since you seem not interested in in-links). The advantage of probeAttr_ is it will return an empty string if the attribute does not exist at the target object. Stop messing around with the "current" module in your code, instead always use functions that explicitly take the module to work with as a parameter. So instead of exists attribute "Object ID from Original" you rather use something like:
AttrDef ad = find (modTarget, "Object ID from Original");
if (!null ad) { ... }
Just as a hint for future coding ... Regards, Mathias Thanks a lot Mathias.:) |