Jump to content

Recommended Posts

Hi,

there is no general command where you can import an arbitrary file into our software. The different files allow different operations/target for importing and therefore this is not possible. You have to program this on your own: Dialog for selecting a file, make the decision which kind of file you have and last but not least you have to call the correct import command (directly scripted).

Regards,

Bernd

Thank you, the problem is that I don't know the general command. I don't know how to tell to the software to use the command

gom.interactive.sys.import_g3d 

IF I find g3d and use

gom.interactive.sys.import_stl

IF I find stl. I don't know if I've made myself clear.

 

Thank you very much.

Please sign in to view this quote.

Marco,

I have a few scripts I've written that do what I think you're looking for. Have you already created a GOM dialog to select the file you're importing? In my script, I check the end of the imported filename with python's ".endswith()" string method and call the appropriate import command based on the file extension. In short, it looks something like this:

filename = #Whatever the return value for your import dialog is

if filename.endswith('.g3d'):
	gom.interactive.sys.import_g3d
elif filename.endswith('.stl'):
	gom.interactive.sys.import_stl 

I don't know that it's the most foolproof method, but it has worked well for my uses thus far. Hope this helps!

Regards,

Michael Henson

Good morning Marco,

Just to try to help.

I would do what Bernd has suggested - take a recording of importing of g3d and stl.

The reason is that this captures all the syntax behind.

In the example Michael has given i dont know if it will work properly.

A good example is that the stl import has syntax for mm or inches , clearly this is important!

When you have the syntax then can substitute into the if statement.

Hope this helps

Hello Marco,

there is no definition of the file in line 50 (location on the hard drive) - this should be entered in your dialog. I would recommend to have a look at our FAQ articles regarding basic scriping functions like dialogs:
https://connect.gom.com/label/GKB/scripting

We also have a training "Python Scripting for GOM Applications" on training.gom.com here:
https://training.gom.com/course/574615

Regards,
Nanno

  • Thank you! 1

Hi Marco, i completely agree with Nanno.  I think you need to get a good base level understanding on how to work with python/gom before launching into anything with any complexity.

 

To give short hints

Things with # in front of them are comments .  They will not be processed by the script

They are primarily there to mark out your code for future ease of reading

Does your dialogue box look correct and you are able to choose a file ?  In the dialog box creator the box that has the file to choose has a name , given on the right

hand side of the dialog creator.

It is this name youll need to reference 

So lets say its name was "nameoffilepathobject"

- Needed code will look something like:

Filepath =DIALOG.nameoffilepathobject

 

Im going to assume that you intend to write something that cycles through a directory to do something? 

This is possible , but being honest I also feel that it would be difficult to give the right level of hints through the forum and without you having a base level understanding of coding in GOM. 

×
×
  • Create New...