Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X
We're interested in SmartAssembly for a project we have. It will involve a model using a number of curves generated from .pts tables. We would want to code both the initial setup, and revisions using new point data. To do one set, it's simply start the offset points operation, set the coordinate system, browse to the table, then done. Making the curve is even simpler. And to update means just edit definition of the pts table, browsing to new, and all that. Doing it multiple times, it's a couple of simple steps, set within a loop, where the names of the tables increment through a preset sequence (TURN01_V1, TURN01_V2, TURN02_V1, etc).
Question is, does smartassembly have this capability, or more specifically, is that something that can be coded for use in smart assembly? I am not looking for the code, just some feedback from SA users as to whether we are looking at the right software?
Yes, it already has that capability. Very straight forward to do.
So if I want to work in a .prt environment, and do coding for the points tables, what is your recommendation for setting up the project. Do I need set up a template, or can I generate my part, and then have smartassembly coding that I can call to add the features.?
SmartAssembly doesn't really create features (other than holes). It can create features by inserting UDFs or running mapkeys, so I guess it just depends on your use case. If you creating these points from scratch is what you want, then just create a UDF that makes the necessary features and then use SmartAssembly to place this in your models. Personally I tend to use template models more and just alter what already exists. Keep in mind that you wouldn't necessarily need to create every single point inside the points feature. The number of points can be adjusted programmatically. I'd also suggest naming the features so they're easy to reference from your program.
When working at the component level in smartassembly, what is the easiest way, starting with a CREO part (not created in smartassembly) to create a project and then step into the area where coding can be done. I am just looking for help with the 1st couple of steps. The manual is a bit less than helpful
What do you mean by 'project'? Are you talking about creating a SmartAssembly program or something else in Creo (assembly, etc.)?
Writing SmartAssembly programs doesn't require Creo to even be running. It's not like other programming languages where you have an editor running connected to an active session of something that you can debug. SmartAssembly programs are just text files that Creo can use SmartAssembly to call (execute.)
Maybe give me an example of something you want to accomplish in Creo and I'll try to describe what that would require in SmartAssembly code.
A .prt contains a curve drawn via a points table in creo (.pts). I want to go through each point in the table and add a set amount to each 'x' coordinate (like an offset), the regen the line.
Thanks for taking time
Henry
Just to be clear, is the same value being added to every point or do you want to add a unique offset value to each point?
I assume that SA, like other coding suites, has the ability to declare and define variables that later can be used in calculations. So for this example, a standard number add is fine. I appreciate your time and are trying not to over-ask
Sample Code:
BEGIN_ASM_DESCR
BEGIN_CATCH_ERROR
USER_INPUT_PARAM DOUBLE Offset_Amount
! Get reference to coordinate system
SEARCH_MDL_REF THIS CSYS "CS0" feat_CS
! Get reference to existing point feature
SEARCH_MDL_REF ALLOW_SUPPRESSED THIS FEATURE "MY_POINTS" feat_Points
! Read in current point values
READ_POINTS_EX feat_Points struct_DTM_PNT
! Create second structure for new values
DECLARE_STRUCT DTM_PNT_OFFSET_CSYS struct_DTM_PNT_2
struct_DTM_PNT_2.type = struct_DTM_PNT.type
struct_DTM_PNT_2.with_dims = struct_DTM_PNT.with_dims
struct_DTM_PNT_2.offset_csys = struct_DTM_PNT.offset_csys
! Add offset value to each point's x value and store in new structure
FOR point REF ARRAY struct_DTM_PNT.array_points
! PRINT "%/%/%" point.x point.y point.z
point.x = point.x + Offset_Amount
ADD_ARRAY_ELEM struct_DTM_PNT_2.array_points point
END_FOR
! Update points feature with new structure values
MODIFY_POINTS_EX feat_Points struct_DTM_PNT_2
REGEN_MDL THIS
END_CATCH_ERROR
END_ASM_DESCR
Here is what is looks like when executed:
(Video is also attached for direct download while this is waiting for approval.)
Thanks Tom
When you created the library item 'edit points', did you create a new project, or did you modify an existing library folder?
'Edit_Points' is the name of the text file (.tab) file that contains the code above. To make it visible in the menu, it needs to be added to the selection list file (sel_list.txt.)
This has been very helpful. So there are cases where I need to replace an entire pts table, rather than an offset of certain values. So I have code which browses to a windows folder (path=filein), and opens a text file which is just the point data (shown below). It also reads it in successfully. What is the easiest way to take that read-in data and use it to populate the new declared structure - is it a line-by-line , or can it just be put in as one?
Sorry, path is 'tablefilepath'