Creating 3D Points from a List

The following was posted by Dave Hurst of WAMware to the ICCON mailing list.

Download Perl File (rename as cr_pts.pl)

Requirement: read a list of 3d point data and create those points in I-DEAS

Approach: Rather than write the program logic in the (IMO unwieldy) I-DEAS programming language, I chose to use perl (which is available on most OS platforms) to output a program file. Of course the method is independent of the language you choose, and you could even do this manually in an editor (with a good search and replace function).

To find the syntax to create 3D points in I-DEAS just run I-DEAS once with the program file create mode on and create some points manually. Here's an example of the resulting file:

K : $ return
K : $ /cr p
K :
K : $ /cr m3 p
K : KEY
K : 1 2 3
K : 3 4 5
K : 3 4 5
K : DON
K : $ mpos :; EXIT
K : N
E : **** END OF SESSION ****


So all the program needs to do is tell ideas to create 3D point in key-in mode (/cr m3 p key), and start listing points.

since point data is of the format
-304.725037 -69.041298 -225.687836
-304.94873 -68.005501 -225.764542
-304.720917 -66.584633 -225.602463


we just need to read the lines, split into separate values and write them to the program file.

Here's a simple version of a perl program to do that.

************************* simple_cr_pts BEGIN
print <<"PRG_START";
K : \$ /ta mm
K : /cr m3 p
K : KEY
PRG_START

while (<STDIN>) {
@pts = split;
printf ("K : %g,%g,%g\n", @pts);
}

print "K : DON\n";
exit;
************************* simple_cr_pts END


We're just using standard input and output here, so using the command perl simple_cr_pts <vessel.pts >vessel.prg creates the vessel.prg program file that you can run in ideas to create your points.

Of course its impossible to write a program file like this without getting distracted by the "creeping elegance" effect. In my case I felt compelled to add a verbose option (call with the command "perl cr_pts.pl -v"), so you can see the program run, but the default is to limit user output to a status update every 1000 points or so. I also noticed a significant degradation in speed with each batch of 1000 points (your data file had 15801 points), so I added a stop_watch info to the list. It might provide a useful, but simple system benchmark The final program file is attached if you're interested.

 
Back Up

back to WAMware homepage®
Copyright © 1996-