Export Points from object into txt file
 1-11  12-31  32-40

Previous
Next
 From:  Frenchy Pilou (PILOU)
9071.12 In reply to 9071.10 
< ImportPointFile script

Ok that was that! the funny is that we must export then import! :)
---
Pilou
Is beautiful that please without concept!
My Moi French Site My Gallery
  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
9071.13 In reply to 9071.11 
Hi dune1982, you can just do those steps that you describe individually, for getting the length of a curve use this:
http://kyticka.webzdarma.cz/3d/moi/#CurveLength

You can decide what length to use based on that, then with the regular Transform > Array > Dir command you can make 500 lines with the spacing you need, you can select all the lines that were just created using this on a shortcut key:
script: moi.geometryDatabase.selectLastCreated();

Then run isect and that SavePointFile plug-in.

Why do you need to combine that into a single 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:  amur (STEFAN)
9071.14 
Hi Michael,

thanks a lot! I completely forgot that this is possible with the import script.

Regards
Stefan
  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:  dune1982
9071.15 In reply to 9071.13 
Since I have to do this task couple of times now and in the future a script would make it easier.

I already got this far (create some lines and put them in a list, but I fail selecting the one line where all the intersections are on)


#include "GetObjects.js"

//Set vareables 
var i;
i=0;
var linelength;
linelength=50;

var linelist = moi.geometryDatabase.createObjectList();


//Will draw a line with the given coordinates 
function drawLine(x1,x2,y1,y2) 
{
   	var linefactory = moi.command.createFactory( "line" );
   	linefactory.setInput( 0, moi.vectorMath.createPoint( x1, y1, 0 ) );
   	linefactory.setInput( 1, moi.vectorMath.createPoint( x2, y2, 0 ) );
	    
	var objlist = linefactory.calculate();
   	var line = objlist.item(0);
	moi.geometryDatabase.addObject( line );
   	return line;
}	


for ( var j=0; j < 17; j++ )
{
	linelist.addObject(drawLine(i,i,0,linelength));
	i=i+10;
}
//works fine until here

	

//Will do the intersection 
function DoIntersect()
{
	
	var objectpicker = moi.ui.createObjectPicker();
	//objectpicker.min = 2;
	
	if ( !GetObjects( objectpicker ) )
		return;
	linelist.addObject(objectpicker);
	
	var factory = moi.command.createFactory( 'intersect' );
	factory.setInput( 0, linelist.objects );
	
	factory.commit();
}

DoIntersect();


for the corresponding .htm file I just copied the content of the intersect.htm

It works so far that MoI asks me to pick objects for the intersection. I assume that the lines created by the scipt are in the linelist, so I just select the one line that crosses all the created lines. But that fails in the errormessage attached

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
9071.16 In reply to 9071.15 
Hi Dune1982,
It seems that you have not posted the code which includes the variable allownothing?
- 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:  dune1982
9071.17 In reply to 9071.16 
Hello Brian,
that is part of getobjects.js wich is a part of the MoI core files.
  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
9071.18 In reply to 9071.15 
Hi dune1982, it looks like the error report is off, the actual error is 2 lines down from GetObjects(), here:

code:
linelist.addObject(objectpicker);


ObjectList.addObject() expects a geomobject while that is passing an objectpicker instead. Also further down for the setInput call I think you need to pass just linelist since it is an objectlist, linelist.objects would be an error.

So something like this:

code:

//Will do the intersection 
function DoIntersect()
{
	
	var objectpicker = moi.ui.createObjectPicker();
	//objectpicker.min = 2;
	
	if ( !GetObjects( objectpicker ) )
	    return;

	var picked_objects = objectpicker.objects;

	for ( var i = 0; i < picked_objects.length; ++i )
	    linelist.addObject( picked_objects.item(i) );
	
	var factory = moi.command.createFactory( 'intersect' );
	factory.setInput( 0, linelist );
	
	factory.commit();
}

DoIntersect();

  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:  pior (PIOR_O)
9071.19 
Hello all, Michael,

Does this SavePointFile script still work for V4, and if yes, where does it write out the file ? I am not getting any prompt for a save location and can't seem to find any .txt file written out.

For context I am currently working on a small DIY project that would require to export out points data from a MOI drawing, to later plot them physically as straight pen lines between each point, in "turtle" fashion, using a small Arduino robot. And while an OBJ export of filled polygon objects seems like a good starting point as it is very human readable, I have been wondering if there is already a way to write out point data (in good order of course) to CSV, which led me to this thread.

[edit] Just found this other thread here where it is mentioned that the script is intended to work on point objects, rather than points from objects.
http://moi3d.com/forum/lmessages.php?webtag=MOI&msg=8996.2
It is giving me a long series of floats, separated by commas. I suppose that they are to be interpreted as X0,Y0,X1,Y1,X2,Y2... and so on ? I suppose the order is maintained from the original object ?

EDITED: 14 Sep 2021 by PIOR_O

  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
9071.20 In reply to 9071.19 
Hi pior,

re:
> It is giving me a long series of floats, separated by commas. I suppose that they are to be interpreted as X0,Y0,X1,Y1,X2,Y2... and so on ?

It should be making a separate line in the text file for every point with an x,y,z value on every line.

Can you please post an example output file where it's all on one line?

Are you using the version from here? :
http://moi3d.com/forum/index.php?webtag=MOI&msg=5124.2


> I suppose the order is maintained from the original object ?

It's going to be in the same order that the point objects are in the geometry database.

- 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:  pior (PIOR_O)
9071.21 In reply to 9071.20 
Hello Michael, thank you for the support as always.

FWIW here is what I am getting when running SavePointFile (most updated version) on 4 points which have been copied from a square shape, drawn in top view (first screenshot). It looks like the line breaks have been ignored altogether somehow ? Whereas the OBJ data for the same shape planar filled before obj export is organized more as expected (second screenshot). I'm on Windows btw.

EDITED: 14 Sep 2021 by PIOR_O

Image Attachments:
Size: 16.1 KB, Downloaded: 45 times, Dimensions: 557x259px
Size: 45.5 KB, Downloaded: 30 times, Dimensions: 859x406px
  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
9071.22 In reply to 9071.21 
Hi pior, if you're using Windows notepad the problem is that it doesn't recognize unix-style newline only line endings.

Try with a more fully functional text editor like notepad++.

- 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:  pior (PIOR_O)
9071.23 In reply to 9071.22 
I see - and I had the answer right there in front of me as it was just a matter of opening that txt in Sublime just like I did with the OBJ. And indeed opening the .txt in it does recognize the lines/structure.

Interestingly enough opening the .txt in some programs that respect the CSV structure and resaving from there seems to generate a .txt that has lines in notepad while still being a clean CSV. So perhaps it could be possible to write out a structure that does both ? But of course not at the cost of doubling the line breaks.

On a related topic : is there a feature in MOI that would convert shapes (with lines, polylines and curves) to segmented shapes, similarly to what the DXF exporter does to shapes and the OBJ exporter does to filled shapes ? The point (!) being to have points that can still describe the curved elements accurately, without resampling the straight lines. A "convert to polygon" feature of sorts :


  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
9071.24 In reply to 9071.23 
Hi pior,

re:
> So perhaps it could be possible to write out a structure that does both ?

Currently there isn't any way to adjust the line endings in MoI's text file output to MS-DOS style but it would not be hard to add in an option for that in the future once v5 betas are underway. For now to get that you would need to open and resave it in a text editor that allows you to control the line endings.

re:
> On a related topic : is there a feature in MOI that would convert shapes (with lines, polylines and curves)
> to segmented shapes, similarly to what the DXF exporter does to shapes and the OBJ exporter does to
> filled shapes ?

You could use the DXF exporter for this purpose, save out to DXF format, with Export type = "3D Curves", and Write curves as "Polylines". Then read the DXF file back into MoI. That should convert curves into segmented lines.

- 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:  pior (PIOR_O)
9071.25 In reply to 9071.24 
All noted - and indeed, the DXF route sounds rock solid. Thanks again !
  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:  pior (PIOR_O)
9071.26 In reply to 9071.25 
By the way, I have another question related to this topic of writing out points data.

Is there any way to control, or at least visualize, the ordering of the points within a shape object ? By that I mean being able to see which point is first and which is last, and flipping this around if needed.
Or, if not possible, is there some clever workaround to force the ordering one way or another ? Like for instance fusing curves in a given order, forcing a recalculation with a trim, and so on.
  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
9071.27 In reply to 9071.26 
Hi pior, try this plugin here:
http://moi3d.com/forum/index.php?webtag=MOI&msg=9781.5

That will let you visualize and adjust the direction of curves. Let me know if that wasn't what you were asking about.

- 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:  pior (PIOR_O)
9071.28 In reply to 9071.27 
Hello Michael,

Well, that seems to be exactly it, thanks ! And I assume the little dot represents the start point on closed curves, which in turn allows me to reassign it another point by making a small gap in the shape where I want the starting to be, and then close the gap again.
  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
9071.29 In reply to 9071.28 
Hi pior, for changing the start/end "seam" point on a closed curve try this one:
http://moi3d.com/forum/index.php?webtag=MOI&msg=10125.8

- 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:  pior (PIOR_O)
9071.30 In reply to 9071.29 
Well, that's exactly it :) Thanks !
  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:  pior (PIOR_O)
9071.31 

Hello again - I actually have another question about this topic.

While I am going through this workflow with more complicated objects/drawings, I find that the SavePointFile command, while being functional, is a bit cumbersome in how it expects a pure selection of point objects. By that I mean that in order to get to these points, I first have to display all the points of a given object or objects, then select them manually (carefully avoiding selecting full curves, which can be near impossible), ctrl-c them, get out of the points display mode, delete the source curve objects, then paste the points. And from there, SavePointFile can then be run on a selection of points.

Is there any clever way to bypass all that by somehow converting any (segmented) curve object to its points only, without any manual selection needed ?
And on a similar topic, is there any way to run ArrayCurve (with a single point as input) on multiple curves at once ?

I hope this makes sense - I'll provide diagrams if that is unclear.

  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

 

 
Show messages:  1-11  12-31  32-40