Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Pro/ENGINEERCustomizationMissingManuals
2
More NextBlog
CreateBlog SignIn
Pro/ENGINEERCustomization
MissingManuals
WebTutorialsforPro/Toolkit,JLink,Pro/Web.LinkandVBAPI
What'sNew
Pro/ToolkitAmystery
As I write this Blog, I travel back in time to find how difficult it was as a
student to acquire grasp on Pro/Toolkit. Even today, if I googled on
"Pro/Toolkit", I will find some good links provided by PTC. There are few
more helpful links on basics of Toolkit (though these sites will also warn
you how hard it is to learn Pro/Toolkit). Trust me, you don't have to be a
PhD or a programming geek to learn how to get things done using
Pro/Toolkit.IhavesloggeditoutbutIwanttomakethismysteryalittlebit
easier to comprehend for the new users and students.I am planning to
startpostingtopicsonPro/Toolkit,Jlink,C,etc.Rememberthebestplace
tolearntheseproductsarethePTCcertifiedtrainingcenters.Thisblogis
going to be a helpful link for the new users as well as for experienced
users for quick reference. For all, there is no better place than the
userguides provided by PTC to all its users.Please bookmark this page
andcomebacksoonformoreinformation.
ADDTHIS
|
More
FEEDCOUNT
RSS
Subscribeinareader
SUBSCRIBETOBLOG
Enteryouremailaddress:
PostedbyAlanPage Nocomments:
Subscribe
TheBIGPicture
Tags
Amystery(1)
Accessfunction(1)
AsynchronousApplication(2)
CadCustomization(5)
DataHandle(1)
IPC(2)
JLink(1)
make_basic(1)
OpaqueHandle(1)
Pro/Develop(2)
Pro/ENGINEERcustomization(3)
Pro/TKApplication(1)
Pro/Toolkit(5)
Pro/toolkittutorial(4)
Pro/Web.Link(1)
PRO_COMM_MSG_EXE(2)
protk.dat(1)
ProToolkit.h(1)
Spawnmode(2)
SynchronousApplication(3)
user_initialize()(2)
user_terminate()(2)
VBAPI(1)
BlogArchive
09(6)
Jun(6)
AsynchronousApplication
Pleaserefertotheattachedimageabove.Toworkonthesetoolswewill
have to install them on the workstation. We may choose the
Pro/ENGINEER loadpoint or let the installer create it for us (Eg.
http://missingmanuals.blogspot.in/
SynchronousApplication
GettingStarted
NutsandBolts
TheBIGPicture
1/11
2/20/2015
Pro/ENGINEERCustomizationMissingManuals
Pro/ToolkitAmystery
TotalPageviews
2 3 7 1 7
TheparentPro/Toolkitdirectoryhasthefollowingdirectorieslistedunderit
1.)i486_ntfolderwhichincludesthemakefiles,alltheLibraryfiles(used
for linking), and few DLL files (compiled Pro/Toolkit example files). This
directory also includes two EXE files (prodialog_view.exe and
ptk_revtool.exe), which are utility files for dialog view and revision tool. I
willbediscussingmoreabouttheseinthesubsequentblogs.
2.) includes folder has all the header files required for Pro/Toolkit.
Rememberyoumayalsoberequiredtousesomeoftheheaderfilesfrom
thePro/Develop*.
3.)protk_applsisthefolderwhichhasthesamplecodesformostofthe
Pro/Toolkit APIs. These sample application files can be compiled using
the makefiles available from the above i486_nt folder. This folder also
hassomeapplicationspecificheaderfilesandmodelfiles.
4.)protkdocfolderhasthedocumentationforALLtheAPIsandtheuser
guide. It is a good idea to create a shortcut for the index.html on the
desktopaswehavetorefertothedocumentationquiteoften.
5.)TherearefewmorefilesintheparentPro/Toolkitfolder:
Followers
Jointhissite
withGoogleFriend
Connect
Members(6)
Alreadyamember?
Signin
FollowbyEmail
Emailaddress...
Submit
TheparentPro/Developdirectoryhasthefollowingdirectorieslistedunder
it
1.)i486_ntfolderwhichincludesthemakefiles,alltheLibraryfiles(used
forlinking),andfewDLLfiles(compiledPro/Toolkitexamplefiles).
2.)includesfolderhasalltheheaderfilesrequiredforPro/Toolkit.
3.) prodev_appls has the sample applications. It also contains the
applicationspecificincludefilesandmodelfiles.
4.)TheparentPro/Developdirectoryalsohastheprodev.datfilewhichis
usedtoregisterthePro/DevelopapplicationinPro/ENGINEER.
JLinkDirectorystructure
2/11
2/20/2015
Pro/ENGINEERCustomizationMissingManuals
1.) jlink_appls folder has sample application showing the use of the
methods.
2.) jlink_tutorial has the sample tutorials and the solutions folder. There
are guidelines to complete these tutorials at the PTC knowledgebase on
thewebsite.
3.)jlinkdocfolderhasthedocumentationforALLtheJavamethodsand
theuserguide.Itisagoodideatocreateashortcutfortheindex.htmlon
thedesktopaswehavetorefertothedocumentationquiteoften.
4.)TherearefewmorefilesintheparentJLinkfolder:
a.) Jlink_Wildfire40_RelNotes.pdf this file has the release note
for the new version of JLink. It covers new methods and any
criticalchangesinthenewrelease.
b.)jlinkug.pdfthisistheuserguide(manual)forJLink.
c.) README this file has helpful information about JLink
installationanduse.
Pro/Web.LinkDirectorystructure
ThistoolisintroducedinWildfire4.0.VBAPIistheVisualBasictoolkitto
access the internal components of Pro/ENGINEER session. You have to
be an experienced Pro/ENGINEER user who is also familiar with Visual
Basicoranotherobjectorientedlanguage.VisualBasic.NET2005isthe
certifiedplatformforthisrelease.
TheparentVBAPIdirectoryhasthefollowingdirectorieslistedunderit
1.)vbapi_applscontainsanprojectonPro/ENGINEERparameters.
2.)vbapi_examplesfolderhasmanysampleapplicationsonVBAPIuse.
3.)vbapidocfolderhasthedocumentationaboutVBAPI.Itisagoodidea
tocreateashortcutfortheindex.htmlonthedesktopaswehavetorefer
tothedocumentationquiteoften.ThereisonemorefilesintheparentVB
APIfolder:
a.) Vbug.pdf this file is the userguide for the VB API users. It
covers the VB API for Pro/ENGINEER in about 350 pages of
document.
_____________________________________________________________
3/11
2/20/2015
Pro/ENGINEERCustomizationMissingManuals
find this information useful. You may subscribe to my blog using the
form on the main page and get the update as and when it happens.
Please let me know if the information in the blog was helpful to you or
not. Also, leave me comments on various technical and nontechnical
aspects on how to improve this blog. I will be glad to incorporate any
good suggestion. I will be posting my first blog on Pro/Toolkit shortly,
stay tuned.
__________________________________________________________________
TRADEMARKS:Pro/ENGINEER,Wildfire,Pro/Toolkit,Pro/Develop,JLink,Pro/Web.LinkandVBAPIaretheregistered
trademarksofPTC(http://www.ptc.com/).Allotherproductsorservicesmentionedinthisblogarethetrademarksorservice
marksoftheirrespectivecompaniesororganizations.
PostedbyAlanPage Nocomments:
NutsandBolts
Inthisandfewsubsequentblogs,IwouldliketointroducePro/Toolkit.It
will be a helpful guide for the new users, experienced user may skip this
section. Throughout this series of blog I will be using a Windows XP
machine and my compiler will be Visual Studio. To keep it simple in the
beginning, I will compile my Pro/Toolkit applications using the command
line arguments of the VC compiler. For UNIX users, I would like to help
thembyemailsiftheyhaveanyspecificrequirement.Youwillberequired
to keep the index.html (APIWizard) started from the
(ProENGINEER_LOADPOINT)\protoolkit\protkdocfolder.
To begin with, new Pro/Toolkit users must know some key stuff as listed
below:
Pro/DevelopThiswasthecustomizationtoolusedinPro/ENGINEERtill
Pro/Toolkit replaced it in the Release 17 of Pro/ENGINEER. Though, we
haveabetterproductinPro/Toolkit,wemaystillusePro/Developtobuild
our application. In fact, there are few areas where there is no equivalent
Pro/Toolkit function and we are required to use Pro/Develop functions.
BothPro/ToolkitandPro/Developusesthesamemechanismtoconnectto
Pro/ENGINEER, so in a single application we may have a mix of both
theseproducts.
protk.datfile This is the file which registers a pro/Toolkit application in
Pro/ENGINEER. It is a text file with .dat extension for Pro/ENGINEER to
recognizeandregistertheapplication.Iwillbetakingacloserlookatthis
filelateron.
Environmentvariables:Therearefewenvironmentvariablesrequiredto
be set for asynchronous application but for synchronous application no
additional environment variables are required to be set. The environment
variable
"PRO_COMM_MSG_EXE"
should
point
to
"
(ProENGINEER_LOADPOINT)/obj/pro_comm_msg.exe" file. The other
environmentvariableslikePro/ENGINEERpath,etcarealreadysetwhen
installing Pro/ENGINEER. Some special environment variables are
requiredforJlink,whichwewillcoverwhenwetouchthattopic.
Synchronous Application: This is the mode of Pro/Toolkit when the
application is registered in Pro/ENGINEER and is controlled by the
Pro/ENGINEERsession.Thisapplicationhasnomain()functionbuttwo
mandatory function called user_initialize () and user_terminate (). The
function user_initialize () is the first function to be visited when the
applicationisbeingcalledfromPro/ENGINEER.Standalonesynchronous
applicationisnotfeasibleasithasnomain()functionanditdependenton
Pro/ENGINEERsessiontomakecallstoit.Therearetwowaysofcreating
asynchronousapplicationSpawnmodeandDLLmode.
Spawn mode: In this mode the executable file interacts with the
Pro/ENGINEER process (xtop.exe) using Inter Process
Communication(IPC).Thismodeisslowerascomparedwiththe
DLL mode but while developing an application, this mode is
recommendedasitiseasiertodebugasmallerapplication.
DLLmode:Inthismodetheexecutable(DLLfile)getsembedded
inside the Pro/ENGINEER process (xtop.exe), while it launches.
This mode is much faster than the spawn mode. This mode
should be used when the application has to be released for the
http://missingmanuals.blogspot.in/
4/11
2/20/2015
Pro/ENGINEERCustomizationMissingManuals
endusers.
AsynchronousApplication:Inthismode,theexecutablefilehasitsown
main()function.Whichmeansitcanexistindependently.Inthismodethe
application makes a call either to connect to an existing Pro/ENGINEER
session or to start a new Pro/ENGINEER session. In this mode the
Pro/ENGINEER process (xtop.exe) and application perform operations
concurrently. There are two forms of Asynchronous application Simple
AsynchronousModeandFullAsynchronousMode.
Simple Asynchronous Mode: In this mode there is no
implementation in the application to handle the request from
Pro/ENGINEER.So,anyevent(userclick,featurefailureetc)will
notbepassedontotheapplicationtoreacttoit.Thisapplication
can start/connect to Pro/ENGINEER session and ask
Pro/ENGINEER to perform some tasks and then disconnect/end
Pro/ENGINEERsession.Noneofthefunctionsoftheapplications
canbeinvokedbyPro/ENGINEER.
Full Asynchronous Mode: In this mode, there is a mechanism to
handle the requests from Pro/ENGINEER. In this mode, the
application has to implement a control loop that waits for
messages from Pro/ENGINEER. In this mode, Pro/ENGINEER
cancallfunctionsintheapplicationalsotheapplicationcanreact
toeventsinPro/ENGINEER.
MSVCVsCommandprompt:Therearetwodifferentwaysbywhichwe
cancompileandcreateanexecutablefileinPro/Toolkit.Thefirstwayisto
create a project in Visual Studio and then compile the code. Though this
mode is very user friendly, it could become a daunting task for the new
userstolearnPro/ToolkitaswellastheoperationsoftheVisualstudio.For
setting up the Visual studio project, please read the chapter 2 of Getting
started guide of Pro/Toolkit in the Wildfire 4.0 installation directory
(Protoolkit_GSG.pdf).IfyouhavepriorexperienceinVisualstudioIwould
highly recommend it. Otherwise for a new user it would be better if we
followthecommandpromptwayofcompilingtostartwithandthenmoving
on to Visual Studio. In the command prompt mode we normally set the
environment variables of the VC compiler in the command window and
thencompileourcodewiththe"nmake"option.Iwillcoverhowwecanset
uptheenvironmentvariablesoftheVCcompilerandcompileaPro/Toolkit
application.IwouldencouragealltousethemakefilessuppliedbyPTC.
Throughout this blog I will use the PTC's makefiles to compile my
applications.
Makefile: I will be covering the Makefile in more details later on. For the
time being you may consider a make file as an instruction file for the
compiler about the various compiler flags to be set while compiling and
linkingtheapplicationtothePro/ENGINEERlibraries.
________________________________________________________
These are the few concepts/terms which should help new users to
accelerate their learning. Again, do let me know if you find this blog
interesting, do leave me a comment; I will be happy to interact with
you. I am signing off for now.
_________________________________________________________
TRADEMARKS: Pro/ENGINEER, Wildfire, Pro/Toolkit, Pro/Develop, JLink, Pro/Web.Link and VB API are the
registered trademarks of PTC (http://www.ptc.com/). All other products or services mentioned in this blog are the
trademarksorservicemarksoftheirrespectivecompaniesororganizations.
PostedbyAlanPage 2comments:
GettingStarted
5/11
2/20/2015
Pro/ENGINEERCustomizationMissingManuals
textinthefileasshownbelow:
~~~~~~~~~~~~~~~~~~~~
Line#23>>EXE=pt_basic.exechangeittoEXE=tkapp.exe(wewill
callourapplication"tkapp")
Line#24>>EXE_DLL=pt_basic.dllchangeittoEXE_DLL=tkapp.dll
Line#27>>PROTOOL_SRC=../../../protoolkitchangeittoPROTOOL_SRC=
[PROE_LOADPOINT]/protoolkit(thisisrequiredforthecompilertoknow
thelocationofthelibraryfileandtheincludefilesofPro/Toolkit)
Line#29>>PRODEV_SRC=../../../prodevelopchangeittoPRODEV_SRC=
[PROE_LOADPOINT]/prodevelop(thisisrequiredforthecompilertoknow
thelocationofthelibraryfileandtheincludefilesofPro/Develop)
Line#73>>OBJS=pt_basic_src.objpt_utils.objchangeittoOBJS=
tkapp.obj(weindicatethattherewillbeanintermediatefilewiththe
nametkapp.objcreated)
Line#94>>pt_basic_src.obj:
$(PROTK_APPLS)/pt_basic/pt_basic_src/pt_basic_src.c
$(CC)$(CFLAGS)$(PROTK_APPLS)/pt_basic/pt_basic_src/pt_basic_src.c
changeittotkapp_src.obj:tkapp.c
Removethelinestartingwith"pt_utils.obj"completely.
~~~~~~~~~~~~~~~~~~~~
Savethefileandexittheeditor.Nowthesecondtaskistogetthesource
codegoing.Tostartwith,wewillwriteasmallprograminPro/Toolkit.As
mentioned in my previous blog, for a synchronous application the
requirement is to have a user_initialize() and a user_terminate() function.
Wewillopenatexteditoragainandwritethecodeasshownbelow(The
nameofthecodefileshouldbetkapp.c):
~~~~~~~~~~~~~~~~~~~~
#include"ProToolkit.h"//Thisincludefileisamust
/********************************/
int user_initialize() // This is a must for sync
applications
{
printf("\nHelloPro/ToolkitWorld!!\n")
return(0)
}
/********************************/
void user_terminate() // This is a must for sync
applications
{
printf("\nGoodbye!!\n")
}
~~~~~~~~~~~~~~~~~~~~
Savethefileastkapp.cinthesamedirectorywhichwascreatedinstep1.
Openacommandpromptandthengotothedirectorywhichwascreated
in step 1. At this point you will have to set the environment for using
Microsoft Visual C++ tools on the command window. You will type
something like this on the command prompt "C:\Program Files\Microsoft
VisualStudio\VC98\Bin\VCVARS32.bat" (The path could vary if you have
the"MicrosoftVisualStudio",installedonadifferentfolder).Afterrunning
thisbatchfile(VCVARS32.bat),youwillgetasystemmessageasSetting
environmentforusingMicrosoftVisualC++tools.
Oncetheenvironmentissetinthecommandprompt,wewillcompilethe
program tkapp.c by using the namke function, we will type nmake f
make_basic. This is going to compile the program and give us the
tkapp.exe which is our first executable Pro/Toolkit application. Please
refertothecommandlinesnapshotbelowformoredetails.
Oncetheapplicationisreadywewillhavetojustmakeaprotk.datfileto
http://missingmanuals.blogspot.in/
6/11
2/20/2015
Pro/ENGINEERCustomizationMissingManuals
For details about the contents of the protk.dat file please refer to PTC
guide for Pro/Toolkit (tkuse.pdf). After having the protk.dat file you may
launch Pro/ENGINEER from the same directory and get the application
runningasshowninthesnapshotbelow:
___________________________________________________________________
PostedbyAlanPage 2comments:
SynchronousApplication
Inthelastblogentrywesawaskeletonprogramwhichstartsassoonas
Pro/ENGINEER starts. The two functions user_initialize () and
user_terminate () are called in succession. In a synchronous application
theuser_initialize()functionisthefirstfunctiontobewhichgetscalledand
onceitiscomplete,theuser_terminate()functioniscalled.Wemayputall
our functions under user_initialize (). Please look at the API wizard for
more details about the user_initialize () and the user_terminate ()
functions.APIwizardisthebestfriendthatanyPro/Toolkitdevelopercan
have.
Wewillbuilduponaskeletonmodeltocraftournextapplication.Thenext
application is going to write the mass properties of any model into the
http://missingmanuals.blogspot.in/
7/11
2/20/2015
Pro/ENGINEERCustomizationMissingManuals
/********************************
Pro/ToolkitIncludesfiles
*********************************/
#include"ProToolkit.h"
#include"ProFeature.h"
#include"ProElemId.h"
#include"ProExtrude.h"
#include"ProModFeat.h"
#include"ProStdSection.h"
#include"ProElement.h"
#include"ProElempath.h"
#include"ProFeatType.h"
#include"ProFeatForm.h"
#include"ProSelection.h"
#include"ProSection.h"
#include"ProMenu.h"
#include"ProMenuBar.h"
#include"ProUtil.h"
#include"ProSolid.h"
#include"ProDtmCsys.h"
/********************************
Globaldefinitions
*********************************/
staticProErrorstatus
static
wchar_t
MSGFIL[]
=
{'f','i','l','e','.','t','x','t','\0'}
/********************************
Constructors
*********************************/
intcall_back()
intwrite_display(ProMassProperty)
/********************************
Access function Start This function determines
whetherthebuttoncreatedintheapplicationshould
bevisibleinPro/ENGINEERornot
*********************************/
static
uiCmdAccessState
(uiCmdAccessModeaccess_mode)
{
ProModemode
ProModeCurrentGet(&mode)
TestAccessDefault
if(mode==PRO_MODE_PART
mode==PRO_MODE_COMPOSITE
mode==PRO_MODE_SHEET_METAL
mode==PRO_MODE_ASSEMBLY
)
http://missingmanuals.blogspot.in/
8/11
2/20/2015
Pro/ENGINEERCustomizationMissingManuals
returnACCESS_AVAILABLE
returnACCESS_INVISIBLE
}
/********************************
user_initialize Function In this section a menu
buttoniscreatedandwhichhasancallbackaction
*********************************/
intuser_initialize()
{
uiCmdCmdIdcmd_id
status=ProCmdActionAdd("TKButton",
(uiCmdCmdActFn)
call_back,
uiProe2ndImmediate,TestAccessDefault,
PRO_B_TRUE,PRO_B_TRUE,&cmd_id)
status
=
ProMenubarmenuPushbuttonAdd("File",
"TKButton",
"TKButton",
"TKButton","File.psh_rename",
PRO_B_TRUE,
cmd_id,MSGFIL)
return(0)
}
/********************************
call_back Function Start This is the call back
function which is getting called when the TKButton
menuispressed.Alltheactionhappendhere.
*********************************/
intcall_back()
{
ProMdlmodel
ProSolidsolid
ProNamename
ProCharNamecname
ProSelection*sel
intn_sel
ProModelitemmodelitem
ProMassPropertymass_prop
ProCsysp_csys
ProNamecsys_name
status=ProMdlCurrentGet((ProMdl)&solid)
if(status)
{
print_s("Themodelcouldnotberetrieved")
}
status
=
ProSelect("csys",1,NULL,NULL,NULL,NULL,&sel,&n_sel)
if(status)
{
return0
}
status
=
ProSelectionModelitemGet(sel[0],
&modelitem)
status=ProModelitemNameGet(&modelitem,csys_name)
status = ProSolidMassPropertyGet(solid,csys_name,
&mass_prop)
write_display(mass_prop)// File output Function
called
http://missingmanuals.blogspot.in/
9/11
2/20/2015
Pro/ENGINEERCustomizationMissingManuals
return(0)
}
/********************************
FilewriteanddisplayFunctionStart
*********************************/
intwrite_display(ProMassPropertymassprop)
{
FILE*fp
ProNamew_filename
ProInfoWindowLocationwin_location={0.5,0.2}
ProInfoWindowSizewin_size={15,80}
char*fname="output.txt"
fp = fopen (fname, "w") /* Any command in between
fopenandfprintfresultsincompilererror*/
fprintf(fp,"\nThemassandvolumeofthepart")
fprintf(fp, "\nMass = %f and Volume = %f ",
massprop.mass,massprop.volume)
fprintf(fp,"\nCenterofgravitywithrespecttothe
selectedCSYS")
fprintf(fp,
"\nX
Y
Z
%f
%f
%f
\n",
massprop.center_of_gravity[0],
massprop.center_of_gravity[1],
massprop.center_of_gravity[2])
fclose(fp) /* important Point, close the file
before using "ProInfoWindowDisplay", or it will
printnothing*/
//DisplayingtheinformationwindowinPro/ENGINEER
ProStringToWstring(w_filename,"output.txt")
status
=
ProInfoWindowDisplay(w_filename,&win_location,
&win_size)
return(0)
}
voiduser_terminate()
{
}
/* The text editor of blogger is very bad, please
execusemypoorformattingofthecode*/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10/11
2/20/2015
Pro/ENGINEERCustomizationMissingManuals
Thanksforyourvaluabletimeinreadingthrough.Ciao...
_________________________________________________________
TRADEMARKS: Pro/ENGINEER, Wildfire, Pro/Toolkit, Pro/Develop, JLink, Pro/Web.Link and VB API are the
registered trademarks of PTC (http://www.ptc.com/). All other products or services mentioned in this blog are the
trademarksorservicemarksoftheirrespectivecompaniesororganizations.
PostedbyAlanPage Nocomments:
Home
OlderPosts
Subscribeto:Posts(Atom)
Thisblogisprotectedbycopyright,pleaseseekpermissionbeforereproducingthisbloganywhere.Simpletemplate.PoweredbyBlogger.
http://missingmanuals.blogspot.in/
11/11