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


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

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

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

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



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


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

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

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

ИндексИндекс  PortalPortal  КалендарКалендар  ГалерияГалерия  Въпроси/ОтговориВъпроси/Отговори  ТърсенеТърсене  ПотребителиПотребители  Потребителски групиПотребителски групи  Регистрирайте сеРегистрирайте се  ВходВход  
Потребителско име:
Искам да влизам автоматично с всяко посещение: 
:: Забравих си паролата!
Social bookmarking
Social bookmarking digg  Social bookmarking delicious  Social bookmarking reddit  Social bookmarking stumbleupon  Social bookmarking slashdot  Social bookmarking yahoo  Social bookmarking google  Social bookmarking blogmarks  Social bookmarking live      

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
Юли 2019


 The Classic First Example Program for WebLink

Go down 

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

The Classic First Example Program for WebLink Empty
ПисанеЗаглавие: The Classic First Example Program for WebLink   The Classic First Example Program for WebLink Icon_minitimeВто 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.bulgarianforum.net
The Classic First Example Program for WebLink
Върнете се в началото 
Страница 1 от 1

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