I am new to Creo coming from Catia.
I have a sketch being extruded up to a complex surface (extrusion in the Z direction).
My input is: total volume of the extrusion. My output should be the z-position of the sketch.
In Catia I have access to a solver where it would iterate through several z-position to match my required total volume.
How can I do the same in Creo?
Either through a solver or through macros.
There is no magic way to do this but there are ways if you can either do the calculation or if you are willing to go through a couple regenerations to get the answer back.
If the volume is simple enough and you can do the math, you can use relations to do the math based on geometry information.
For more complex geometry, you can make a more complex model to calculate the negative volume using analysis. in this case, you actually have to make a "volume" part and subtract your actual part and let analysis return the volume of the "negative" part.
You can use values across parts but your head will swim before you get it all worked out. Watch out for circular references.
The tricks are always useful when the software is limited.
Unfortunately in my case I do need a robust approach that can be scaled up (i.e. complex geometry + more variables).
Is there a macro approach that would enable me to change the z parameter of my sketch and get the volume of the part. If I can set this up as a function, I am happy enough to setup a solver (bissection or better) around this.
I wasn't suggesting anything rouge... just a bit of setup work. It can be quite robust, but you have to enter the z-value, and you can have a relatively easy time of evaluating the volume outcome. What is more difficult with complex geomtery is to put in the volume value and have it give you Z.
The feature you want to use is the merge feature. You would make an assembly with the "volume" model and your "container" component. You use a saved analysis feature in your "volume" part to determine the effects of your change in "Z" of your "container" part. You can do all this from your assembly model and you can even have annotation on the screen do the readbacks for you.
There is a solution to do iterative calculations.
You can use an "Excel Analysis".
This will allow you to include an excel file containing very complex calculations and iterations.
All you need to do is:
1) create the excel file
2) make it so that the input is concentrated in A1 - A2 - A3 - A4 - ...
3) the same for the output
4) create the excel analysis, and send the input parameters to the right excel cells
5) retrieve the correct cells from excel , and put it in usable parameters for creo.
In excel, you can include a simple VBA script to automatically iterate. (function goalseek)
This is a very powerful feature if you need complex calculations, or even if you need to retrieve a set of parameters from a large database...
I read your question again, and I thinked of a better solution for your problem:
1) in your part, create a parameter "Z_VALUE" (or "HEIGHT")
2) make it default 1 (for example)
3) create the sketch and extrusion
4) add a feature relation, and make the extrusion height equal to parameter "Z_VALUE"
5) add a measurement feature, and measure the surface area of the extruded part
6) create a feature with this measurement, the area will be in a parameter.
7) create a relation (a feature relation in a next feature or a relation in the part itself) with this calculation:
"Z_VALUE = [requested volume] / AREA_of_measurement_feature"
after 1 or 2 regenerations, the height should be correct.
I included an example.
Look at the parameters in the main part and in the measurement feature.
Look at the relations in the main part and in the Extrude feature.
Hope this solves your problem.