Skip to main content
20-Turquoise
November 21, 2014
Question

How to get a weblink "pfcBaseSession" object?

  • November 21, 2014
  • 4 replies
  • 2664 views
Creo Parametric 2.0 M130

I want to use weblink to get the current value of a config option.In my case I want to get the value
of start_model_dir.

According to CS122393 it should be as simple as using pfcBaseSession.GetConfigOption(). However when
I attempt to do this:
var startModelDir = pfcBaseSession.GetConfigOption("start_model_dir");

I get a javascript error:
pfcBaseSession is not defined

So obviously there is more to this than what CS122393 states.

Does anybody have a working code snippet that uses any of the pfcBaseSession weblink methods they
would be willing to share?

Thanks

--
This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.

4 replies

1-Visitor
November 22, 2014
Good morning,

if you want to learn how to start with Weblink it is neccessary to read the "Introduction" chapter in the Weblink API documentation.
There are examples how to get the session object and the important pfcCreate() method.

The Weblink API doc can be found in the folder <creo_installation_dir>/Common Files/M130/weblink/weblinkdoc.

Andreas
MikePhillips
12-Amethyst
November 24, 2014
Randy,

Try this

var session = pfcCreate("MpfcCOMGlobal").GetProESession();

var dir = session.GetConfigOption("start_model_dir");

Regards,


Mike Phillips
Raytheon

-----Randy Jones <-> wrote: -----
20-Turquoise
November 24, 2014
On 11/24/14 09:55, Michael D1 Phillips wrote:
> Randy,
> Try this
> var session = pfcCreate("MpfcCOMGlobal").GetProESession();
> var dir = session.GetConfigOption("start_model_dir");

Perfect!
That is exactly what I needed but couldn't arrive at from the weblink users guide or the javascript
examples.

I had tried all combinations of
var baseSession = pfcCreate("MpfcBaseSession");
var baseSession = pfcCreate("pfcBaseSession");

and then
baseSession.GetConfigOption("start_model_dir");


Thanks.

> Regards,
> Mike Phillips
> Raytheon
>
> -----Randy Jones <-> wrote: -----
> To: -
> From: Randy Jones <->
> Date: 11/21/2014 03:09PM
> Subject: [proecus] - How to get a weblink "pfcBaseSession" object?
>
> Creo Parametric 2.0 M130
>
> I want to use weblink to get the current value of a config option.In my case I want to get the value
> of start_model_dir.
>
> According to CS122393 it should be as simple as using pfcBaseSession.GetConfigOption(). However when
> I attempt to do this:
> var startModelDir = pfcBaseSession.GetConfigOption("start_model_dir");
>
> I get a javascript error:
> pfcBaseSession is not defined
>
> So obviously there is more to this than what CS122393 states.
>
> Does anybody have a working code snippet that uses any of the pfcBaseSession weblink methods they
> would be willing to share?
>
> Thanks
>
> --
>
1-Visitor
May 9, 2015

Hi Randy,

If it's still relevant on the following link found following solution:

  • The variable is a handle of the active Creo session. It could be retrieved (Interface) and could not be instantiated
  • we can simple get via casting pfcBaseSession <=> pfcSession
  • Example:

session=(new ActiveXObject ("pfc.MpfcCOMGlobal")).GetProESession ();
//the GetProESession returns a pfcSesson object

session.GetConfigOption("regen_failure_handling");
//pfcBaseSession method from a pfcSession object is automatic get along the
// inheritance of the object

Regards,

Aduard