Continue to Site

Welcome to MCAD Central

Join our MCAD Central community forums, the largest resource for MCAD (Mechanical Computer-Aided Design) professionals, including files, forums, jobs, articles, calendar, and more.

STL export of components from assembly

dabbya

New member
Hi All,

I am trying to export STL files of individual components from Pro-E assembly using Pro/Toolkit.

I am using the function the ProOutputFileWrite to create STL files
while cycling through all parts in the assembly. This function gives me
the individual STL files but the STL files are exported with respect to
the coordinate system of the individual parts.



I would like to have an STL export with respect to their location in
assembly which will enable me to just import all files in their proper
location.

Otherwise I would like to haveProMatrix that gives me the location of the part with respect to the assembly coordinate system.

For this I am using the function ProAsmcomppathTrfGet. This requires me to pass in the ProAsmcomppath for each component.



Can anybody please help me by giving some example of how to get the
ProAsmcomppath for each part in the assembly. It seems that most of the
examples provided by PTC work only on ProSelection which I do not have.




Alternatively, any method to directly export the solids with respect to
the locations in assembly will be also be greatly appreciated.



Thanks for your help in advance.



Regards,

Abhijit
 
Use the function ProAsmcomppathInit. You must initialize the component id table to -1 and then I'm pretty sure it will give you the proper component path. Here is the example from the help.





comp_id_table[0] = -1;
status = ProAsmcomppathInit(assembly, comp_id_table, 0,
&asm_data.comp_path);
 
Hi Patrick,



I am querying each individual file using a visit function. I tried
calling the function ProAsmcomppathInit with the argument as the ProMdl
for assembly.



Am I supposed to again call this function for each individual component
so that I get the ProAsmcomponentpath for each component separately?



If yes then what should be the argument for this function when used for individual component?



If I am not supposed to call this function for each individual
component but only once for top level assembly, then how would the
function ProAsmcomppathTrfGet understand which component's transformation matrix is it supposed to return.



I apologise if this question seems silly but as of now I am totally
baffled by all the identity matrices that I get as a result of query
using ProAsmcomppathTrfGet function.



Please help me with the arguments for these functions.



Thanks again for your help.



Regards,

Abhijit
 
Abhijit,


Ok, let's back up. You are trying to get the transformation matrix for each component of the assembly in order to output an STL file with the proper matrix as it assembles into the top level assembly. That part I understand.


Here is how I would accomplish that.


1. Call ProSolidFeatVisit on the top level assembly. Pass the address of the ProAssembly (the handle to the top level assembly) in the ProAppdata argument.


2. In the filter function, filter out any feature that is not a PRO_FEAT_COMPONENT (ProFeatureTypeGet). Also filter out any suppressed components (ProFeatureStatusGet).


3. In the action function, call ProAsmcompMdlGet to get a handle to the component model. Call ProAsmcomppathInit with the handle to the solid and the top level assembly handle (ProAppdata passed in step 1). This will get you what you need for the ProAsmcomppathTrfGet function.


4. Now output your STL file.


There may be some functions that I missed but that explains the overall concept. Hope this helps.
 
Hi Patrick,



I apologise for not posting my query for all these days. I could not
work on that query for some days and now I am trying to nail this STL
export function.



As per the suggestions, I have completed the first two steps.



I have some doubts in the third step. I would be grateful if you can please clarify them.



In ProAppdata argument I pass a ProAssembly handle.

In the action function, I cast this as (ProSolid).

Thus first input for ProAsmcomppathInit is (ProSolid) ProAppdata.ProAssembly



I get a feature as a input for action function.

I set comp_id_table[0] = feature->id and comp_id_table[1] = -1 as given in the example.



My third argument is integer 1 and last value is the path to initialize i.e. ProAsmcomppath.



Thus the final function looks like



ProAsmcomppathInit ( (ProSolid)top_level_assembly_handle, comp_id_table, 1, &comp_path );



Is this correct or am I doing any wrong step.



Nextly I use the function

ProAsmcomppathTrfGet(&comp_path, PRO_B_FALSE, matrix);



This returns me a 4X4 matrix with no translation or rotation values.
Instead I either get an identity matrix or the matrix indicates some
projection by giving values in the fourth row.



Can you please go through above steps and point out any mistake I am doing?



For your information, I am not making any call to ProAsmcomppathInit in
the UserAsmCompVisit function. Do I need to make such and use the
values obtained in this function.



Thanks for all your help again.



Regards,

Abhijit
 
Hi Patrick,



Thanks for uploading the code as an example. Your example and explanation earlier have helped me immensely.

I had got all part of the code that you explained correctly and can output the matrices for individual parts.



The only problem that I still face is that the matrices have values in the fourth row.

As an example please see this matrix.

1.00 0.00 0.00 0.00

0.00 1.00 0.00 0.00

0.00 0.00 1.00 0.00

0.00 -4.35 -0.09 1.00



This values in last row suggest that the part has different projection.

The part has only been trnasformed using rotation and translation. Ideally
for rotation the first 3X3 matrix should have values and for
translation, the first three rows in last column should have some
values.

The last row should always be 0 0 0 1.

Matrix from assembly to part or part to assembly do not change the
location of the entry for numbers. Only the numbers are changed. Thus a
argument PRO_B_TRUE or PRO_B_FALSE does not make any difference.



Is there a specific way that these matrices are to be interpreted? Are
these the general homogenous matrices used in maths or a different
method of denoting devised by Pro/E. A better way to frame my question
would be "How do I take the matrices and transform the component
exported with respect to coordinate system in part so that it will
allow me to assemble without needing to specify any mating conditions"?



I hope I made my doubt clear.



Thanks again for all your help.



Regards,

Abhijit
 
Abhijit,


Look in the API Wizard under User's Guide->Coordinate Systems and Transformations. That section will tell you how to interpret the values in a ProMatrix object. As for an answer to your question, I don't know. You're just going to have to try it. You will probably have to do a matrix inversion depending on your True/False parameter for ProAsmcompPathTrfGet. You will have to then transform the part according to that matrix and then output the STL. By the way, what ProImportExportFile type are you giving ProOutputFileWrite?
 
Hi Patrick,



Thanks again for your help. I will read that part of the documentation. I missed reading that earlier and its seems helpful.



As for ProImportExportFile type, I am using PRO_SLA_ASCII_FILE.



Thanks again.



Regards,

Abhijit
 

Sponsor

Articles From 3DCAD World

Back
Top