Batch modeling operations

Next
 From:  jpvikholm
8193.1 
Hi,

I have several files and each of them contains one extruded profile. Extruded profile is along x-aksis and it's start point is in 0,0,0 and end point is in 1000,0,0.

Would it be possible to create script that...
- erases part of the extrusion leaving only start profile in yz plane
- rotates start profile to xy-aksis
- ... and saves file and goes to next

Any link to related tutorial would be greatly appreciated :)


Regards,

Jukka-Pekka Vikholm
  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
8193.2 In reply to 8193.1 
Hi Jukka-Pekka, it would probably help clarify things if you could post one of the files as an example.

- 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
Next
 From:  jpvikholm
8193.3 In reply to 8193.2 
Hi Michael,

Yes of course. Here is one.


Regards,

Jukka-Pekka Vikholm
Attachments:

  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:  bemfarmer
8193.4 In reply to 8193.3 
Select all of the edges of the solid beam.
Copy the edges to curves.
Delete the solid.
Go through the curves one by one, testing the start points and the end points, testing for non-zero x coordinate.
Delete any curves that have such a non-zero x coordinate in such points.
Join the remaining curves.
Rotate the profile, about the origin, 90 degrees in the top Frame.
Rotate the profile, about the origin, -90 degrees in the right Frame.
This places the "tips" of the beam profile in the +y direction.
Save file.
Process next file.
- 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

Previous
Next
 From:  Michael Gibson
8193.5 In reply to 8193.3 
Hi Jukka-Pekka, thanks for posting the example file. Could you also post an example of the desired output? That would then help to clarify some additional things like if you're looking for a planar face as output or if you are looking for curves as the output.

Also when you say "goes onto the next" file, how would the script know what the next one is, is there a particular naming convention to them or do you mean pick it from a file dialog ?

Thanks, - 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
Next
 From:  jpvikholm
8193.6 In reply to 8193.5 
Hi,

Here is a sample of the profile that I'm after.

Thank You Brian and Michael. I'm mainly after planar face but also planar edges/curves would be great for future use.

What goes to process... Common thing about the files is that profile that I would like is in yz-plane. ...so maybe testing if all face or curve points are on that plane and then making proper slectionset, inverting it and deleting other parts from the model? I don't believe that rotation is a problem after wanted objects are only ones left in model.

I was thinking a system like Your BatchConvert/Convert. I remember seeing that one can define a directory that Convert utility goes through. What goes to filenames I would prefer original filenames since each profile is already in its own file.


Regards,

Jukka-Pekka Vikholm
Attachments:

  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
8193.7 In reply to 8193.6 
Hi Jukka-Pekka, thanks for posting the additional file. I'll see if I can cook up a script for you tomorrow or the next day after.

- 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
Next
 From:  jpvikholm
8193.8 In reply to 8193.7 
Hi Michael,

It's always pleasure to see what you come up with :)


Regards,

J-P
  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
8193.9 In reply to 8193.8 
Hi Jukka-Pekka, sorry it's going to take me a couple more days before I can get some work done on this script.

- 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
Next
 From:  jpvikholm
8193.10 In reply to 8193.9 
Hi Michael,

Please take Your time :)

- J-P
  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
8193.11 In reply to 8193.8 
Hi J-P, please try the attached script, I think it should do the kind of batch processing you wanted.

There are instructions for installing a plug-in here. This script doesn't show any UI so it only has a .js file, not any .htm file.

Please note that the batch processing changes all the 3DM files in the given directory, any piece that is not in the world YZ plane will be deleted, and the 3DM file will be resaved in place so make sure you have backups of these files before processing them.

Before running it, use a text editor to change the directory name at the top of the script.

Hope it does what you were looking for!

- Michael
Attachments:

  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:  jpvikholm
8193.12 In reply to 8193.11 
Hi Michael,

Instructions and code it self are very clear. I don't think there will be any problems. I try this as soon as I'm on my main computer later today.

Thank You again Michael! You provide excellent support :)


- J-P
  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:  jpvikholm
8193.13 In reply to 8193.12 
Hi Michael,

This really does what it should :)

How ever I have one more request. Can I have modified version that leaves only edges/curves?


Thank You again.

- J-P
  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
8193.14 In reply to 8193.13 
Hi J-P, no problem! For your modified version, insert the following code just below the object rotations inside the ProcessFile() function:

code:
	// Duplicate edges of any remaining surfaces and delete the surface.
	var RemainingSurfaces = gd.getObjects().getFaces();
	for ( var i = 0; i < RemainingSurfaces.length; ++i )
	{
		var Srf = RemainingSurfaces.item(i);
		var Edges = Srf.getEdges();
		for ( var j = 0; j < Edges.length; ++j )
		{
			var Edge = Edges.item(j);
			var DupEdge = Edge.clone();
			gd.addObject( DupEdge );
		}
		
		gd.removeObject( Srf.getParentBRep() );
	}


- 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
Next
 From:  mkdm
8193.15 In reply to 8193.13 
Hi jpvikholm.

If you want you could also add this little extra code, just below latest code that Michael sent you.

code:
var joinFactory = moi.command.createFactory( 'join' );
joinFactory.setInput( 0, gd.getObjects().getCurves() );
joinFactory.commit();


This code simply join all resulting curves that can be joined.

Best,

- Marco (mkdm)
  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:  jpvikholm
8193.16 In reply to 8193.15 
Hi,

Excellent! All this makes things much easier. I had approximately 2500 profiles to convert and now it's all done. No headache, blurry vision or pain in the hands .... great!

It seems that I will be digging Moi3D little deeper from now on :)


Thank You Michael & Marco,

- J-P
  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