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

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

how to get creo view URL for a representation of CAD Document?

gmydoor-2
10-Marble

how to get creo view URL for a representation of CAD Document?

HI all,

 

Using below API  I am able to get representations for EPM document. Is there any API to get creo view URL of a representation? 

 

VisualizationHelper visualizationHelper = new VisualizationHelper();
QueryResult epmReps = visualizationHelper.getRepresentations(epm);

 

ACCEPTED SOLUTION

Accepted Solutions
HelesicPetr
22-Sapphire I
(To:gmydoor-2)

Hi @gmydoor-2 

The result of getRepresentations should contain files for Creo view.

If you need to download them then use 

 

try
{
	Representation defaultRep = RepresentationHelper.service.getDefaultRepresentation(cadDoc);
	Vector<ApplicationData> vectorOfAppData = ContentHelper.getContentListAll(defaultRep);
	Iterator<ApplicationData> appIter = vectorOfAppData.iterator();
	while (appIter.hasNext())
	{
		ApplicationData syAppData = appIter.next();
		ContentHolder holder = ContentHelper.service.getContents(defaultRep);
		final URL viewContentURL = WVSContentHelper.getViewContentURL(syAppData, holder);
		final URL downloadURL = WVSContentHelper.getDownloadURL(syAppData, holder);
	}
} catch (WTException | PropertyVetoException e)
{
	e.printStackTrace();
}

 

PetrH

View solution in original post

5 REPLIES 5
HelesicPetr
22-Sapphire I
(To:gmydoor-2)

Hi @gmydoor-2 

The result of getRepresentations should contain files for Creo view.

If you need to download them then use 

 

try
{
	Representation defaultRep = RepresentationHelper.service.getDefaultRepresentation(cadDoc);
	Vector<ApplicationData> vectorOfAppData = ContentHelper.getContentListAll(defaultRep);
	Iterator<ApplicationData> appIter = vectorOfAppData.iterator();
	while (appIter.hasNext())
	{
		ApplicationData syAppData = appIter.next();
		ContentHolder holder = ContentHelper.service.getContents(defaultRep);
		final URL viewContentURL = WVSContentHelper.getViewContentURL(syAppData, holder);
		final URL downloadURL = WVSContentHelper.getDownloadURL(syAppData, holder);
	}
} catch (WTException | PropertyVetoException e)
{
	e.printStackTrace();
}

 

PetrH

Thanks for the response. @HelesicPetr 

Hi @HelesicPetr 

 

Is there an API to generate the creoview URL(creoview://?wcparams=...) that launches the Creo View application for a given list of part(s) with the version?

Note : There is this OOTB REST endpoint(../Windchill/servlet/rest/visualization/objects/) that does it with OID and version, just curious if it can be done via API and also for a list of parts.

Hi @MV_10441462 

If you check the open representation link, then you can see that the API has to exist

HelesicPetr_0-1726057013200.png

PetrH

 

Here's some code I wrote recently that returns a URL which opens the default representation of a given object in CreoView...

 

public static String getCreoViewURL(WTObject object) {

		System.out.println("==> getCreoViewURL");
		String url = "";

		try {
			
			VisualizationHelper visualizationHelper = VisualizationHelper.newVisualizationHelper();
			QueryResult representations = visualizationHelper.getRepresentations(object);
			if (representations != null) {
				while (representations.hasMoreElements()) {
					Representation representation = (Representation) representations.nextElement();
					if (representation.isDefaultRepresentation()) {
						ContentHolder holder = ContentHelper.service.getContents(representation);
						String downloadURL = WVSContentHelper.getDownloadURLForType(holder, ContentRoleType.PRODUCT_VIEW_ED);
						url = "'/Windchill/wtcore/jsp/wvs/edrview.jsp?url=" + downloadURL + "&objref=OR%3A" + holder.toString() + "'";
					}
				}
			}
					
		} catch (Exception e) {
			System.out.println(e.getMessage());
		}
		
		System.out.println("<== getCreoViewURL");
		return url;
		
	}

 

Announcements

Top Tags