How to move objects in DOORS

After importing from a spreadsheet, you are left with a flat import in DOORS, i.e. there is no object hierarchy. For large documents it would be better to have script that implements this for you after importation. If every row in the spreadsheet has an attribute called "Object level", this sounds like a feasible task. I've attached my DXL code, as well as the spreadsheet I'm importing, and also a picture of how the final result in DOORS should look like. 

So if anyone can take a look at my code (it's very short) and explain to me why i get the error message "-R-E- DXL: <Line:43> cannot move object: destination is same object" and maybe suggest improvements, I would be very gratefult


kip820 - Tue Jun 25 07:13:38 EDT 2013

Re: How to move objects in DOORS
Richard_Good - Tue Jun 25 07:54:40 EDT 2013

Something like the following should work for you the "Level" attribute contains the level you want the item to be at, this can be imported from csv and filled by an excel macro to count the full stops in Object Heading or the like.

 

Module RVM= current
Object ObjArray[20]
Object PrevObj, RVMObj
bool FirstObj=true
int ThisLev, PrevLev
int n=0

for RVMObj in RVM do n++
Object RMArray[n]
int ObjCount=n
n=0
RVMObj = first RVM
for RVMObj in RVM do RMArray[n++]=RVMObj
PrevLev=1

 

for(n=0;n<ObjCount;n++) {
 RVMObj=RMArray[n]
 ThisLev = RVMObj."Level"
 if (FirstObj) {
 }
 else if (ThisLev >  PrevLev ) {
  //insert under last object, update object array
  move(RVMObj, last below PrevObj)
 }
 else if (ThisLev ==  PrevLev  ){
  //insert at same level as previous, update object array
  move(RVMObj, PrevObj)
 }
 else {
  //insert as next object after own level, update array
  move(RVMObj, after ObjArray[ThisLev])
 }
 ObjArray[ThisLev] = RVMObj
 PrevObj = RVMObj
 PrevLev =ThisLev
 FirstObj=false
}

Re: How to move objects in DOORS
kip820 - Tue Jun 25 08:20:58 EDT 2013

Richard_Good - Tue Jun 25 07:54:40 EDT 2013

Something like the following should work for you the "Level" attribute contains the level you want the item to be at, this can be imported from csv and filled by an excel macro to count the full stops in Object Heading or the like.

 

Module RVM= current
Object ObjArray[20]
Object PrevObj, RVMObj
bool FirstObj=true
int ThisLev, PrevLev
int n=0

for RVMObj in RVM do n++
Object RMArray[n]
int ObjCount=n
n=0
RVMObj = first RVM
for RVMObj in RVM do RMArray[n++]=RVMObj
PrevLev=1

 

for(n=0;n<ObjCount;n++) {
 RVMObj=RMArray[n]
 ThisLev = RVMObj."Level"
 if (FirstObj) {
 }
 else if (ThisLev >  PrevLev ) {
  //insert under last object, update object array
  move(RVMObj, last below PrevObj)
 }
 else if (ThisLev ==  PrevLev  ){
  //insert at same level as previous, update object array
  move(RVMObj, PrevObj)
 }
 else {
  //insert as next object after own level, update array
  move(RVMObj, after ObjArray[ThisLev])
 }
 ObjArray[ThisLev] = RVMObj
 PrevObj = RVMObj
 PrevLev =ThisLev
 FirstObj=false
}

Thank you for your reply, I'll start studying the code at once

Re: How to move objects in DOORS
Mike.Scharnow - Tue Jun 25 09:08:41 EDT 2013

kip820, besides the problem that the logic you implemented will not work  (compare your approach to Richard's), there is another problem:

currentObj = current   // holds the current object
"current" is the object which has been activated, where you clicked on. I think you wanted to state 

currentObj = o

Re: How to move objects in DOORS
kip820 - Tue Jun 25 09:32:09 EDT 2013

Mike.Scharnow - Tue Jun 25 09:08:41 EDT 2013

kip820, besides the problem that the logic you implemented will not work  (compare your approach to Richard's), there is another problem:

currentObj = current   // holds the current object
"current" is the object which has been activated, where you clicked on. I think you wanted to state 

currentObj = o

Thanks, it seems I had completely misunderstood what "current" does/mean, thank you for clearing that up, my script works as intended now!

I probably wasn't clear enough when stating my problem, but I was looking for a way to automate the function "Demote object(Ctrl+Alt+Right)" so that an object hierarchy/depth could be created automatically for large documents, instead of manually going through the module in "Demoting" ebejcts, for example, subsection should be one level below section, requirements listed in a subsection should be one level below the subsection etc.

Thanks both of you for informative answers :)

Re: How to move objects in DOORS
PRM - Tue Jun 25 19:32:56 EDT 2013

A possible alternative is to use a script created by Michael Sutherland that uses an attribute to guide the script into building the object hierarchy for you. Click here to have a look at a similar topic where I have supplied some instructions, screen grabs and a copy of Michaels DXL script - it is in the context of importing from a spreadsheet and then building the hierarchy, in your case, the flat object structure is already in a module so this will be your starting point.

Paul Miller
Melbourne, Australia

Re: How to move objects in DOORS
kip820 - Wed Jun 26 04:00:04 EDT 2013

PRM - Tue Jun 25 19:32:56 EDT 2013

A possible alternative is to use a script created by Michael Sutherland that uses an attribute to guide the script into building the object hierarchy for you. Click here to have a look at a similar topic where I have supplied some instructions, screen grabs and a copy of Michaels DXL script - it is in the context of importing from a spreadsheet and then building the hierarchy, in your case, the flat object structure is already in a module so this will be your starting point.

Paul Miller
Melbourne, Australia

Thanks a lot, I hadn't seen that you replied to my other post as well :) Michael Sutherland's script look very robust, It's hard to find extensive  tutorials on DXL so I think I should study his script to maybe learn a few tricks