Skip to main content
1-Visitor
May 18, 2016
Solved

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

  • May 18, 2016
  • 9 replies
  • 5342 views

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.

Best answer by 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

9 replies

12-Amethyst
May 18, 2016

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

~Jamie

prathi1-VisitorAuthor
1-Visitor
May 18, 2016

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();

  }

  }

12-Amethyst
May 18, 2016

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;

}

1-Visitor
May 18, 2016

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

prathi1-VisitorAuthorAnswer
1-Visitor
May 24, 2016

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