I've a requirement where in I need to automate a shaft modeling and drafting. There are many segments in the shaft that will have spur gear or a helical gear. The number of segments and type of segment is an user input. Hence the shaft has to be generated in runtime. To do that I was planning to keep different types of segments built in separate files and based on the user requirement the program will chose a segment and copy the features from the respective file and paste it in to the current model being built. It is possible to copy paste features in native Creo2. Is there a function in jlink/tool-kit/otk api that could do this? Or is there any other work around?
To be honest, I wouldn’t do it by copy and paste. I would create a 200% Model linked with a 200% Drawing. Provide an interface for all the options you have. Then resume/suppress features and modify dimensions and parameters. This will save you a lot of time. If 80% of the drawing stuff will regen, you will be a hero. Don’t forget - Start simple, it could end up as a nightmare 🙂
Sometimes it is good to step away from the code and look at the bigger picture.
Can this be done as a master model/drawing with Pro/PROGRAM and save off new versions?
If not, What about a UDF for these features?
One of the biggest temptations when automating Creo is to build from from ground-zero every step that a user does to get to a final design and drawing.... in code.... Specifically - every step from an empty model to a featured model, every step from an empty drawing to a final detailed drawing.
In the end - most of that effort is wasted when someone still has to clean up things to finalize the model / drawing because of API limitations.
So - my suggestion, take advantage of what Creo gives you for FREE.... stable regenerations.
IF your design can be parameterised (dimensional modifications and/or feature existence by logic and sizes)... then simply build a master model of the design ... AND ... a master drawing that is detailed the way you want it to be.
If you do this right... the drawing elements (e.g. views, shown dimensions and notes) will automatically toggle on/off based on the model's regenerated state. So your drawing is detailed correctly EVERY TIME once you set it up and test it for changes.
Pro/PROGRAM is PERFECT for doing this at the model level - then letting the drawing "just respond to change" from the model.
Annotation Features make this a BREEZE - and can be easy controlled by Pro/PROGRAM Logic in the model.
PTC gives you a LOT of FREE stuff due to this parametric and logic controlled relationship.... so use it whenever you can and avoid trying to "code" your automation unless you really need to... even then -- always try to rely on the FREE stuff PTC gives you by relationship / logic.
So - when you regenerate your model / drawing to the correct state (every time if you do it right)... then (optionally delete unused features relations) and ultimately do a SAVE AS operation on both to the new file / drawing name for release ... and you have a new design / drawing... with hardly any cleanup requirements.
Less "code" and more "results" is the goal.
Focus on the data flow and what will react / respond - always take advantage of what Creo is doing by default.
Hope that helps / inspires.