• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk PLM 360

    Reply
    *Expert Elite*
    ScottMoyse
    Posts: 1,266
    Registered: ‎06-10-2009

    String cannot be cast to com.dms.scripting.wrappers.PartWrapper

    53 Views, 3 Replies
    11-21-2012 12:36 PM

    What does this script error mean?

     

    [WorkPack_Calcs_Create] java.lang.ClassCastException: java.lang.String cannot be cast to com.dms.scripting.wrappers.PartWrapper

     

    this is the code:

     

    //=========== sets the related product's Work Allocations ======================//

    setLists();

    //=========== sets the current Items Number ======================//

    item.NUMBER = item.RELATED.CONTRACT_NUMBER + "-" + item.DECK + "-" + item.AREA;

    if (item.AREA <= 9)
    {item.WORK_PACK_NUMBER = item.DECK + "0" + item.AREA;}
    else
    {item.WORK_PACK_NUMBER = item.DECK + item.AREA;}

     

    setLists code is:

     

    function setLists(){

    var desc = item.descriptor.descriptor;
    var tempProduct = null;

    if(item.RELATED_TEMP === null){
    item.RELATED_TEMP = item.RELATED.descriptor.descriptor;
    }
    else if (item.RELATED === null && item.RELATED_TEMP !== null){
    tempProduct = new parentObject(item.RELATED_TEMP.descriptor.dmsID);
    tempProduct.removeItem(desc);
    item.RELATED_TEMP = null;
    }
    else if(item.RELATED.descriptor.descriptor !== item.RELATED_TEMP.descriptor.descriptor){
    tempProduct = new parentObject(item.RELATED_TEMP.descriptor.dmsID);
    tempProduct.removeItem(desc);

    //item.RELATED_TEMP.RELATED_WORK_ALLOCATIONS = removeItem(item.RELATED_TEMP.RELATED_WORK_ALLOCATIONS, item.descriptor.descriptor);
    item.RELATED_TEMP = item.RELATED.descriptor.descriptor;
    }//end if



    if(item.RELATED !== null){

    var product = new parentObject(item.RELATED.descriptor.dmsID);
    product.addItem(desc);

    }//end if
    }

     

    function parentObject(dmsID){
    this.myObject = loadItem(dmsID);

    this.addItem = function(descriptor){
    if(this.itemExists(descriptor) === false){
    var currentValues = this.returnItems(descriptor);
    currentValues.push(descriptor);
    this.myObject.RELATED_ITEMS = currentValues;
    }
    };

    this.itemExists = function(descriptor){
    if(this.myObject.RELATED_ITEMS === null){return false;}
    for (var i = 0; i < this.myObject.RELATED_ITEMS.length; i++) {
    if(descriptor === this.myObject.RELATED_ITEMS[i].descriptor.descriptor){
    return true;
    }
    }
    return false;
    };

    this.returnItems = function(){
    var currentValues = [];
    if(this.myObject.RELATED_ITEMS === null){return currentValues;}
    for (var i = 0; i < this.myObject.RELATED_ITEMS.length; i++) {
    currentValues.push(this.myObject.RELATED_ITEMS[i].descriptor.descriptor);
    }
    return currentValues;
    };

    this.removeItem = function(descriptor){
    var currentValues = [];
    for (var i = 0; i < this.myObject.RELATED_ITEMS.length; i++) {
    if(descriptor !== this.myObject.RELATED_ITEMS[i].descriptor.descriptor){
    currentValues.push(this.myObject.RELATED_ITEMS[i].descriptor.descriptor);
    }
    }

    this.myObject.RELATED_ITEMS = currentValues;

    };
    }

     

    But the error is within the first set of code.

    Cheers
    Scott Moyse

    Please use Mark Solutions!.Accept as Solution &Give Kudos!Kudos to further enhance the value of these forums. Cheers!


       

    Please use plain text.
    *Expert Elite*
    ScottMoyse
    Posts: 1,266
    Registered: ‎06-10-2009

    actually the error is within the setlists library code....

    11-21-2012 12:40 PM in reply to: ScottMoyse

    actually the error is within the setlists library code.

     

    I commented it out and now the script runs error free. This used to work. 

    Cheers
    Scott Moyse

    Please use Mark Solutions!.Accept as Solution &Give Kudos!Kudos to further enhance the value of these forums. Cheers!


       

    Please use plain text.
    Product Support
    michelle.stone
    Posts: 155
    Registered: ‎02-21-2012

    Re: actually the error is within the setlists library code....

    11-21-2012 12:53 PM in reply to: ScottMoyse

    Scott - which line did you comment out?

     

    Thanks,

    Michelle



    Michelle Stone
    PLM Product Manager
    Autodesk, Inc.
    Please use plain text.
    *Expert Elite*
    ScottMoyse
    Posts: 1,266
    Registered: ‎06-10-2009

    Re: actually the error is within the setlists library code....

    11-21-2012 03:17 PM in reply to: michelle.stone

    //=========== sets the related product's Work Allocations ======================//

    setLists();

    //=========== sets the current Items Number ======================//

     

    I stopped the call to the setLists library script

    Cheers
    Scott Moyse

    Please use Mark Solutions!.Accept as Solution &Give Kudos!Kudos to further enhance the value of these forums. Cheers!


       

    Please use plain text.