cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

Translate the entire conversation x

get representation from part

LH_10747950
12-Amethyst

get representation from part

Hi so I'm working on this Thing that takes information from windchill, and puts it though a calculator to return times for the part. but is there anyway to use an O data connector or any feature to get a representation from windchill, there is the WRS partGetRepresentation but I do not know how to implement that into a service that can be called with a part Id or number, I currently am using getJSON to get the urls but that needs credentials in the code but is there a way to avoid having to log in each time by doing it another method that doesnt need to login.

var url = "XXXXXXXXXXXXXXXXXX/Windchill/servlet/odata/v7/ProdMgmt/Parts('" + input + "')/Representations";

var result;

try {
   var response = Resources["ContentLoaderFunctions"].GetJSON({
   		url: url,
        username: user,
        password: pass,
        timeout: 10                                        
    });

    if (response.value && response.value.length > 0) {
        var rep = response.value[0];

        // Check for valid 2D/3D thumbnail URLs
        if (rep.TwoDThumbnailURL && rep.TwoDThumbnailURL.URL) {
            var imageURL = rep.TwoDThumbnailURL.URL;
            logger.warn("2D image URL: " + imageURL);

            try {
                var imageResponse = Resources["ContentLoaderFunctions"].LoadImage({
                    url: imageURL,
                    username: user,
                    password: pass
                });
                result = imageResponse;
            } catch (imgErr) {
                logger.error("Image load failed: " + imgErr.message);
                result = null;
            }
        } else {
            logger.warn("No valid thumbnail URL found.");
            result = null;
        }
    } else {
        logger.warn("No representations found.");
        result = null;
    }
} catch (err) {
    logger.error("Windchill fetch failed: " + err.message);
    result = null;
}

 

ACCEPTED SOLUTION

Accepted Solutions

Found a solution, not the fastest solution i think but it does work but you can use the service GetSearchResults in the thing NavigateSearchThing, that returns an infotable with search results which can be filtered for the version needed and a column is a TwoDThumbnail which can be extracted.

View solution in original post

2 REPLIES 2

Hi @LH_10747950 

Thank you for your question. 

Your post appears well documented but has not yet received any response. I am replying to raise awareness. Hopefully, another community member will be able to help.

Also, feel free to add any additional information you think might be relevant. It sometimes helps to have screenshots to better understand what you are trying to do.

 

Best regards,


Catalina
PTC Community Moderator
PTC

Found a solution, not the fastest solution i think but it does work but you can use the service GetSearchResults in the thing NavigateSearchThing, that returns an infotable with search results which can be filtered for the version needed and a column is a TwoDThumbnail which can be extracted.

Announcements

Top Tags