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

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

How to fetch URL of CAD Drawing (EPM Document) ?

prathi
1-Newbie

How to fetch URL of CAD Drawing (EPM Document) ?

Hi,

We create a CAD Part in Creo and its corrosponding Drawing in Creo. Then we Check both of them into Windcill with Auto Association, so a WTPart corrosponding to them gets created. We need the URL of the Drawing which we created in Creo.We just need UL so that we can open it in Creo View.

We tried using UIHelper.getLaunchProductView but gives us the URL of CAD Part.

We also tried using WVSContentHelper.getDownloadURL but it is giving us 5-6 URL links (which has Partnumber. jpg/log/ol/pvs/plt/pvt/pvm as extensions) but we need only one and that too that of Drawing.

Please suggest how to do this.

1 ACCEPTED SOLUTION

Accepted Solutions
prathi
1-Newbie
(To:prathi)

Hi All,

We tried multiple attempts and finally could get the Drawing Link URL, however with a workaround.
We used - URL aURL = WVSContentHelper.getDownloadURL(data, holder); to get the URLs and then filtered using  - if ( aURL.toString().contains("pvs") ) to get the desired URL. However, as was mentioned by Jamie, this URL in itself does not opens as it requires other files from the zip of Representation to open it, so we manually appended the other parts of URL to make it similar to that URL which we get after saving the Representation as a Link.
Thank you all for your help.

Regards,

Prasad Rathi

View solution in original post

9 REPLIES 9
jmomber
9-Granite
(To:prathi)

You could try wt.content.ContentHelper. It has a getDownloadURL function.

~Jamie

prathi
1-Newbie
(To:jmomber)

I tried using wt.content.ContentHelper.getDownloadURL function, but still it is giving me 5-6 URLs of the extensions as mentioned before. I just need one URL which would open that Drawing.
This is what I have written -

if ((epmm.getNumber().endsWith(".drw")) || (epmm.getNumber().endsWith(".DRW")))

  {

  Representation defaultRep = RepresentationHelper.service

  .getDefaultRepresentation(epmm);

  ContentHolder holder;

  try {

  holder = ContentHelper.service.getContents(defaultRep);

  Vector contents = ContentHelper

  .getContentListAll(holder);

  ApplicationData data = null;

  for (int i = 0; i < contents.size(); i++) {

  if (contents.get(i) instanceof ApplicationData) {

  data = (ApplicationData) contents.get(i);

  URL aURL = WVSContentHelper.getDownloadURL(

  data, holder);

  System.out.println("URL3" + aURL.toString());

  URL bURL = wt.content.ContentHelper.getDownloadURL(holder, data);

    System.out.println("URL2" + bURL.toString());

  

  }

  }

  } catch (PropertyVetoException e) {

  // TODO Auto-generated catch block

  e.printStackTrace();

  }

  }

jmomber
9-Granite
(To:prathi)

You could filter by content type....SECONDARY or PRIMARY

if(data.getRole().equals(ContentRoleType.SECONDARY))

{

      url = ContentHelper.getDownloadURL.......

}


You could also possibly look at the url itself to see if it contains the extension you're looking for. If you found it, just break out of your "contents" loop.

if(appData.getRole().equals(ContentRoleType.SECONDARY))

{

      url = ContentHelper.getDownloadURL..........toString();

     if (url.contains(".pdf"))

     break;

}

jmomber
9-Granite
(To:jmomber)

We use similar code to get the drawing representation pdf, which is why I'm looking at the SECONDARY content and for the url to contain .pdf.

prathi
1-Newbie
(To:jmomber)

We need the drawing in either .dwg or .pdf, but both are not there in the URLs which we are getting by wt.content.ContentHelper.getDownloadURL.
However, when we click on the Thumbmail on the details page of Drawing in Windchill we get the drawing in .pdf and the URL contains .pvs
But the URL having .pvs is displaying a Blank Screen.

jmomber
9-Granite
(To:prathi)

I don't have a lot of experience with Creo View, but if I download reps (right click > Save Representation from the Representation/Annotations table) and save as a .zip, and then copy the .pvs to another location, the .pvs won't open in Creo View because it needs the other files, which is why I'm guessing you're getting the blank screen when you only supply the .pvs URL to Creo View. I'm not sure why you're not getting a pdf URL. Just curious, if you download the reps and save to a .zip, is there a pdf in the .zip?

jmomber
9-Granite
(To:jmomber)

I found this helpful once upon a time when I was working with reps. Not sure if it will help in your scenario, but it's kind of cool to see what content exsits for an object.

<windchillURL>/wtcore/jsp/wvs/listcontent.jsp?oid=<examples below>&showoctree=true

Examples:

wt.part.WTPart:<ida2a2>

wt.viewmarkup.DerivedImage:<ida2a2>

wt.epm.EPMDocument:<ida2a2>

satre-2
1-Newbie
(To:prathi)

You can use com.ptc.netmarkets.util.misc.NetmarketURL.buildURL API to get the URL for object.Below few lines of code might help you.

                       VisualizationHelper helper = new VisualizationHelper();

                       QueryResult qr = helper.getRepresentations(epmm);

                       Representation representation = getLatestRepresentation(qr);

                       String URL= getInfoURL(representation);

               

               

               

                public static String getInfoURL(WTObject object) throws WTException {

                                NmOid contentOid = new NmOid(object);

                                NmURLFactoryBean urlFactoryBean = new NmURLFactoryBean();

                                urlFactoryBean.setRequestURI(NetmarketURL.BASEURL);

                                String URL = com.ptc.netmarkets.util.misc.NetmarketURL.buildURL(

                                                                urlFactoryBean, Type.OBJECT, Command.VIEW_OPEN, contentOid, null);

                                return URL;

                }

Thanks

Shreyas

prathi
1-Newbie
(To:prathi)

Hi All,

We tried multiple attempts and finally could get the Drawing Link URL, however with a workaround.
We used - URL aURL = WVSContentHelper.getDownloadURL(data, holder); to get the URLs and then filtered using  - if ( aURL.toString().contains("pvs") ) to get the desired URL. However, as was mentioned by Jamie, this URL in itself does not opens as it requires other files from the zip of Representation to open it, so we manually appended the other parts of URL to make it similar to that URL which we get after saving the Representation as a Link.
Thank you all for your help.

Regards,

Prasad Rathi

Top Tags