Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create a command line utility 1

Status
Not open for further replies.

WillOMalley

Computer
Mar 10, 2004
18
I have been tasked with one heck of a challenge.
Let me tell you a little about me. I am a computer programmer working for a company in Elmira Ny, I have been programming in several languages now for about 4 years but this will be the first time I have gotten to work with Pro Engineer

We are using Pro Engineer 2001. The challenge is to create a command line utility that would explode through an assembly file and give me all the drawings that are called out.

C:\ GetAllDrawingsFor.bat MyAssembly.asm

I have been doing a lot of reading today to try to get a foot hold on this but all the information that I find is not quite what I am looking for.

Thank you for the help
William O'Malley
 
Replies continue below

Recommended for you

The names of the parts used for an assembly are stored as txt in the assembly file if you were to open it with a text program. You can have your program search through the text in your assembly file by searching for occurrences of .prt and searching and copying the text back to the character that comes before the part names ie ' or " you'd have to open your assembly file and find the preceeding character.

You could output the file names you find. If your company uses the same name for the .prt and .drw files then you should be all set. If not maybe you have another naming convention or consider using the same file names.

Michael
[pc3]
 
So I could read in a .asm file searching for .prt or .dwg files that are called out in the asm file?

That is great.

Thank you so much for the help
 
WillOMalley,

You can search into an .asm file for the .prt and/or .asm files. The drawing files (.drw) are not called into an .asm

If you want to see the .drw files search them directly on the folder.

But I suggest you do not thrust this method. Pro/E will store a lot of garbage and you can find ghost files or interchanges files that actualy are not used. And the problem becomes more complex if the restructure command were used and then some of the files were erased from the disk. Pro/E will still keep the file name in .asm

And another important thing. In .asm file you will not able to see the extension of the component called. Only the component name only. So you cannot tell if the component is an assembly or is a part. And if is an assembly, then you have to scan also this assembly to see the components called. And if there is another 10 or more assemblies called? Did you think at this?

A better way is to use Pro/Toolkit and C language to visit an assembly file. Is more elegant and accurate.

-Hora.
 
Yes I did start thinking about how I would know what type of file I was looking at. There were also some other issues that poped up.

I have been trying to get into the PRO Engineer Toolkit. I am using Wildfire. I am a programmer but have very little experience with the C and C++ language. Do you have a sample program that I could look at to see how to list files that are called out in an assembly?

And you are right, I have one assembly that has several dozen assembly's called out... very messy..

Thank you very much for the help.
 
WillOMalley,

You should create program that will call a Pro/E session (asyncronous mode). Then you can search the assembly with ProSolidFeatVisit function to collect components. If you never ever programmed Pro/E using the Pro/Toolkit functions, it will be a little painfull because of lack of information, tutorials etc, etc.

Note that you will always need a Pro/E license to obtain the result desired if you decide to use this method, and again you will not be able to see the drawings. Only assembly the structure.

Take a look at the They have a program called Fro/Tools which can maybe does what you need.

-Hora
 
it would be nice if we could get an off the shelf solution for this but I am afraid that, that is not an option.

I have been reading about asyncronous access to Pro Engineer Wildfire and I do have a valid license.

When I try to build my project I get errors with my include files. I have added all the links that I need for the pro toolkit.. includes, libs.. but I still get errors.

well I will keep at it but, I have to admit. I am starting to wonder why this is so hard to program to..

thanks
will
 
well after a long talk with my boss, we have decided to go about this another way. Here is what we would like to do.

As Pro\W Wildfire is looking for each feature of an assembly I need to get the name of that component.

Then connect to SQL Server 2000 and check to see if that file has been checked out for read. If it has then don't do anything. But if the user has not checked out the file then check it out for them

So now I need to figure out how to get the names of the files that Pro\E is trying to load. What would be the best way to do this?

Thank you again for all the help
William O'Malley
 
Will,

You shold not be frustrated. It's Pro/Toolkit.

Try your program in sycronous mode first, by creating a .dll file which can be called within Pro/E.

I created for you the user_initialize().You need to create the file assembly.aux (use notepad or wordpad)





int user_initialize()
{
int assyMenuId;


ProMenuFileRegister("assembly", "assembly.mnu", &assyMenuId);
ProMenuAuxfileRegister("assembly", "assembly.aux", &assyMenuId);

ProMenubuttonActionSet("assembly", "CollectComponents", UserStartUp, NULL, 0);

return 0;

}


int UserStartUp(void *a, int b)
{

... your code here

return PRO_TK_NO_ERROR;
}



void user_terminate()
{
return;
}



Content of assembly.aux starts immediately:
ASSEMBLY
@
@
Collect#Components
Perform an Assembly Visit
@


IMPORTANT: do not add the "@" at the begining of the line. I put the sign there only to show you that you must let the blank line as is. The number of blank lines is importatnt. No other blank lines than these are permited. Be careful.

Good luck,

-Hora
 
Will,

I missed your last post and now I see you are using Wildfire, so my first routine will not work for you due to the fact that Wildfire has not anymore right menus. You should replace my code lines with other for the top menus.

I have no ideea about wildfire and SQL link.

-Hora
 
thank you again for all the help.
I just have to create the aux file in the text directory
I think the file path is C:\PTC\Wildfire\Text

When I do create this file do I need to create a .dat file to call it?

thank you again
william o'malley
 
Will,

Without a .dat file you cannot launch your application. Create a file protk.dat and put in in ....Wildfire\text\ folder. Your .dat file should be something like this:

Put your application in your desired folder. The .aux file must be in \text\ folder of your application, and not the \text\ folder of ProENGINEER installation. See my example below.

NAME MyApplication
EXEC_FILE c:\ptc\proe2001\apps\myapp\myapp.dll (example)
TEXT_DIR c:\ptc\proe2001\apps\myapp\text (example)
STARTUP dll
ALLOW_STOP true
REVISION 21
END

Search for more info in the Pro/Toolkit manulal, at the begining of the book.

-Hora
 
Well.. Intralink would be nice but costs a lot of money. The comapny that I work for is not really willing to go for the extra money. So I am stuck developing this application..

Even with all the articles and examples that you can find for the Pro Toolkit ( I could not get ANY of the code to run... Not sure why...
I think that is why I am having such a hard time getting my head around the tolkit.

Untill today I had the white flag raised and was ready to let this idea go for a little while. Thank GOD for Hora who has been nice enough to take my hand and walk me through this. I got an error while trying to load a menu. Well an error is better then nothing.

Thank you all again for the help. I will continue to try to get samples to run..
I am using Visual Studio 2003 Framework 1.1

If you know of any downloadable examples that work please post the links..

William O'Malley
 
Will,

Your program should have these both routines:

int user_initialize()

and

void user_terminate()
{
return;
}

The first one should contain at least one ProToolkit API call.

My example will not work with Wildfire, but will not generate any error code, for simply fact I wrote it for Pro/E 2001 right menu.

If you already created your menu buttons, then call my UserStartUP routine. See below:

int UserStartUp(void *a, int b)
{
char message [100];

sprintf(message, "My first coding for PROENGINEER\n");
UserMessageDisplay(message);

return PRO_TK_NO_ERROR;

} // END UserStartUp

void UserMessageDisplay(ProCharName message)
{
ProFileName msgfil;

ProStringToWstring(msgfil, "message.txt");
ProMessageDisplay(msgfil, "USER %0s", message);

return;

} // End UserMessageDisplay


Good luck

-Hora.
 
I did try the above code and got an error on compile. It said that ProMessageDisplay does not take 3 arguments.. So I looked in the ProMessage.h file
Here is the declaration:

extern ProError ProMessageDisplay(
#ifdef PRO_USE_VAR_ARGS
ProFileName file_name,
ProCharLine message_name,
...
#endif
);

I am wondering if the definition of this function is what is causing the problem.

I also had compile errors with the user_initialize() function.. No worries I am sure that I will get it.. just has not clicked yet.

Thank you again to Hora and everyone else that offered help on this.

William O'Malley
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor