ФОРУМ за света на PTC CREO CAD/CAM/CAE софтуерните решения
Здравейте,


office@cadcamcae.bg

www.soft.cadcamcae.bg - Софтуерни решения за машиностроене;

www.forum.cadcamcae.bg - Форум;

www.blog.cadcamcae.bg - Блог;

http://e-shop.cadcamcae.bg - Електронен CAD магазин;

http://www.facebook.com/cad.digest

http://twitter.com/cadcamcae

3D инженерни мишки;

Поздрави

ФОРУМ за света на PTC CREO CAD/CAM/CAE софтуерните решения

ФОРУМ: Част от проекта на списание CAD ДАЙДЖЕСТ - www.cadcamcae.bg;

CAD ДАЙДЖЕСТ . Едно онлайн издание за CAD/CAM/CAE технологии и машиностроене
 

ИндексИндекс  PortalPortal  CalendarCalendar  GalleryGallery  Въпроси/ОтговориВъпроси/Отговори  ТърсенеТърсене  ПотребителиПотребители  Потребителски групиПотребителски групи  Регистрирайте сеРегистрирайте се  ВходВход  
Вход
Потребител:
Парола:
Искам да влизам автоматично с всяко посещение: 
:: Забравих си паролата!
Social bookmarking
Social bookmarking Digg  Social bookmarking Delicious  Social bookmarking Reddit  Social bookmarking Stumbleupon  Social bookmarking Slashdot  Social bookmarking Furl  Social bookmarking Yahoo  Social bookmarking Google  Social bookmarking Blinklist  Social bookmarking Blogmarks  Social bookmarking Technorati  

Bookmark and share the address of ФОРУМ за света на PTC CREO CAD/CAM/CAE софтуерните решения on your social bookmarking website
Новини от twitter.
Latest topics
Търсене
 
 

Display results as :
 
Rechercher Advanced Search
Споделете с приятел.
Споделете форума В,,, с,,,в,,,е,,,т,,,а,,, н,,,а,,, CAD/CAM/CAE/PLM i Вашия форум за социално споделянеBookmark and Share
Навигация.
 Portal
 Индекс
 Потребители
 Профил
 Въпроси/Отговори
 Търсене
Декември 2016
НедПонВтоСряЧетПетСъб
    123
45678910
11121314151617
18192021222324
25262728293031
CalendarCalendar

Share | 
 

 The Classic First Example Program for WebLink

Предишната тема Следващата тема Go down 
АвторСъобщение
Admin
Admin


Male Брой мнения : 795
Местожителство : София, България
Job/hobbies : CAD/CAM специалист
Reputation : 3
Points : 5303
Registration date : 27.03.2008

ПисанеЗаглавие: The Classic First Example Program for WebLink   Вто 13 Май - 14:56:04

The Classic First Example Program for WebLink

Getting started with WebLink is a challenge because there aren't many examples provided by PTC. There are a few good examples in there, but they represent only a small fraction of the API. This together with the sometimes complex browser security issues can make WebLink seem unapproachable.

In the interest of getting you up and running with WebLink, I'll discuss some of the major hurdles and provide a good, basic starting point.

On Windows, the Internet Explorer browser security model may require the following:

WebLink HTML page must be served by a web server
URL may need to be fully qualified (i.e. http://srv1.yourcompany.com/... not just http://srv1/...)
Internet Explorer should consider your web server as a "trusted host"
config.pro option WEB_ENABLE_JAVASCRIPT must be set to ON


For WebLink that may be enough, but if using other COM objects, such as interfacing with MS Excel for example, changes to IE security settings may be required to grant your application more privileges. This is also a security risk, so be careful when doing this.


The Hello World example is self contained other than loading the (PTC provided) pfcUtils.js file. This file can be placed in the same folder on the web server as the HTML file. The example has a small form containing an anchor tag (with id of "mesg") and a button. The button executes the HitMe() function which populates the contents of the anchor tag.

In nearly every application the pfcGetProESession() function is called, which is contained in the pfcUtils library file. The try/catch block around it verifies that the embedded browser is used, which is essential.

Once we have the session object, the current model object is obtained, from which we can get the name of the model. This value is displayed along with a message in the anchor tag. The try/catch block here helps verify that there is an active model (part, assembly, or drawing), because "model" will be null if there isn't. Trying to call any method against null is pretty much guaranteed to throw an exception.

WebLink Hello World Example:

<HTML><SCRIPT LANGUAGE="JavaScript" type=text/javascript src="pfcUtils.js"></SCRIPT><BODY><SCRIPT LANGUAGE="JavaScript">function HitMe() { if (!pfcIsWindows()) netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var form_elem = document.getElementById("mesg"); var modelname = "no model"; var session = null; var model = null; try { session = pfcGetProESession(); } catch (e) { form_elem.innerHTML = "ERROR: Cannot connect to Pro/Engineer session!"; return; } try { model = session.CurrentModel; modelname = model.FileName; } catch (e) { // probably no model form_elem.innerHTML = "Make sure a model is active!"; return; } form_elem.innerHTML = "Hello! My name is: " + modelname;}</SCRIPT><form name="f"> <INPUT name="btn1" type=button value="Hit me!" onclick="HitMe()"> <br><a id="mesg"></a></form></BODY></HTML>
If you have any questions, please ask. Comments and questions are welcome.
Върнете се в началото Go down
Вижте профила на потребителя http://cadcamcae-bg.top-forum.net
 
The Classic First Example Program for WebLink
Предишната тема Следващата тема Върнете се в началото 
Страница 1 от 1

Permissions in this forum:Не Можете да отговаряте на темите
ФОРУМ за света на PTC CREO CAD/CAM/CAE софтуерните решения :: PTC CREO 3.0: СОФТУЕР ЗА МАШИНОСТРОЕНЕ :: CREO 3.0: Моделиер от висок клас (бивш Pro/ENGINEER Wildfire)-
Идете на: