Modification of ImportPointFile script

Next
 From:  bemfarmer
11383.1 
Hi Michael,

In order to modify the PointImportFile script, to add the name of the text file to the object create (a curve), would the final line of code below do the job?
Or is there a better example?

Thank you,
- Brian


code:
/

Code from _ImportObj.htm:


				objName = moi.filesystem.getFileNameFromPath(objPath);
				objName = objName.substr(0, objName.lastIndexOf('.'));

faceobj=scale3d.calculate();
				
		moi.geometryDatabase.addObjects(faceobj);
		// if ( normalize ) if (scale > 1) { objName = objName + " ["+scale+":1]" }
		// else if (scale < 1) { objName = objName + " [1:"+Math.round(100/scale)/100+"]" }
		if (errors>0) objName = objName + " err:"+errors;
				faceobj.setProperty( 'name', objName);
***************



Code from ImportPointFile.js:

function ImportPointFile()
{
	var filename = moi.filesystem.getOpenFileName( 'Choose a point file', 'Point files (*.txt, *.xyz, *.csv)|*.txt;*.xyz;*.csv|All files (*.*)|*.*' );
	if ( filename == '' )
		return; // User canceled.
***************


Other code from ImportPointFile.js:


	else
		ObjectList = GetCurve( ImportAs, PointList, CurveEnd );
	
	ObjectList.setProperty( 'selected', true );
	moi.geometryDatabase.addObjects( ObjectList );
***************	
Proposed code to add???:
	objName = filename.substr(0, filename.lastIndexOf('.'));
	ObjectList.setProperty( 'name', objName);
	



I would also like the whereabouts of an example of "bulk selection" of filenames to import, if possible?

EDITED: 7 Apr 2024 by BEMFARMER

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
11383.2 In reply to 11383.1 
Hi Brian,

re:
> In order to modify the PointImportFile script, to add the name of the text file to the object create
> (a curve), would the final line of code below do the job?
> Or is there a better example?

It looks fine to me, does it work ok?


> I would also like the whereabouts of an example of "bulk selection" of filenames to import, if possible?

If you want to process all the files in a certain directory, there is an example here of using
moi.filesystem.getFiles() to get a list of files contained within a folder,
http://moi3d.com/forum/index.php?webtag=MOI&msg=6689.2

Like this:
var files = moi.filesystem.getFiles( 'c:\\iges_files', '*.igs' );

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  bemfarmer
11383.3 In reply to 11383.2 
Thank you very much Michael,

The ability to import all of the .xyz files in a directory should be very helpful.

I will do some testing...for both coding.

- Brian
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All