Line order and direction
 1-20  21

Next
 From:  Franz
9781.1 
Hallo!

Is there a way to arrange the sequence and direction of lines or splines, for example for the preparation of laser cuts?

Thanks for a tip.

Franz
  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
9781.2 In reply to 9781.1 
Hi Franz, sorry no there isn't currently a method for controlling the order that curves will be listed in an exported file. They will just be in the order that they were created in.

There is a Flip command that can be used to flip the direction of an open curve but there isn't a way to display the direction currently:
http://moi3d.com/3.0/docs/moi_command_reference10.htm#flip

- 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:  BurrMan
9781.3 In reply to 9781.1 
Hi Franz,
Usually your CAM package has a way to deal with this....

Also, other formats may hold a "joined entitys" properties.....

Do you have any acceptable format options?

What is the CAM software. Proprietary conversational or an independant software option...

More info would help. Maybe a sample file.
  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:  Franz
9781.4 
Hi!

The laser device works with software LaserGrbl - a Chinese toy. It can generate a NC code from the import of a *.svg (Inkscape). Since I can draw in Moi the fastest and don't want to bother with Inkscape, I draw in Moi and export the line drawing into a pdf. Then I convert this into a *.svg in Inkscape. Here I found out after a long research how the order and direction of the lines works. This *.svg imported into LaserGrbl works in an optimized laser process. A bit complicated, but it is just a hobby for me.

It would be nice to have a function in which you could arrange the lines in the desired order by clicking on them in Moi and create a flow in the desired direction with a script that would mark every starting point of a line or spline (to rotate with flip-command if necessary). Would save a lot of work. Then Moi would also be very good for CNC milling in combination with other programs, because nowhere is drawing so fast as in Moi.

Possible is order (click) and direction of lines assigned in alphacam, but this software is very expensive. Does anyone know a simple, inexpensive software where these steps are also easily possible?

Best regards,
Franz.

New insight (20 04 28):
Curves can be arranged with copy and paste!
Then just flip and everything is ready.
A display of the starting point of the curve would be valuable!

I would have a strategy for a script that would be valuable here:
Copy, delete and paste a curve by script (so that the curve is placed at the end ... and so on). At the same time the script creates a new style with the number 1... 2 ... 3 ... (until the last curve, same color). In this way, the curves would be ordered in a controllable way. The same script should simultaneously make ONLY the starting point visible, so that the direction can be changed afterwards with "flip". And that was it.
Is there anyone who is able to deal with this?
I would like to thank you already now.
Franz

EDITED: 27 Apr 2020 by FRANZ

  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
9781.5 In reply to 9781.4 
Hi Franz,

re:
> It would be nice to have a function in which you could arrange the lines in the desired
> order by clicking on them in Moi and create a flow in the desired direction with a script
> that would mark every starting point of a line or spline (to rotate with flip-command
> if necessary).

Hi Franz, I realized that with the new annotation arrows it should now be possible make a script to do this. The arrows should do a good job for showing curve direction.

Please give the attached plug-in a try. Pick the curves by clicking on them in the order you want, then it will show the directions and allow you to click on curves to flip any that are needed.

When the command finishes it will set the curves in the geometry database in their selected order so they should be ready to export then. Looks like this:



Hope that helps! - Michael

EDIT: small update to select the curves when it finishes so they're all ready to export.

EDIT2: another update to make it work with MoI v3 also, but for v3 only the start point will be shown and not direction arrows.

EDITED: 16 Sep 2021 by MICHAEL GIBSON

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:  Frenchy Pilou (PILOU)
9781.6 In reply to 9781.5 
Tricky!
Select Edges then Move them...


French version ;)
http://moiscript.weebly.com/ordre-courbes.html

EDITED: 27 Apr 2020 by PILOU

  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:  wayne hill (WAYNEHILL5202)
9781.7 In reply to 9781.5 
Hi Michael,

Are you able to change the starting point of a closed array?
I used the join command before the order curves and it links them all to one direction!

Edit: I figured out how to change the starting point by unjoining and starting over. Would like to be able to select a closed group, then select an intersect as a starting point.

Thank you,
Wayne

EDITED: 28 Apr 2020 by WAYNEHILL5202

  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:  Franz
9781.8 In reply to 9781.6 
Hi Michael!

Thank you, Michael. It ist a great an useful thing.
I will give a message from the use next time. Your really made me happy.

Franz
  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:  Subpa (SUBPATH2)
9781.9 
Hi all

Im a kind of a silent forum reader ;-)
And longtime Moi Fan, sience Version 1.


Hi Franz

A little to late and Michael has the better solution
but anyway. I think you can use Inkscape for that too.

make a path in Inkscape

go to preferences
and under Nodes
turn on "Always show outline"
and "Show path direction on outlines"

now you see the direction of your path

go to Menu "Path" there is a "Reverse" Command
where you could change the direction of your path


greetings
subpath2 (subpa)
  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
9781.10 
Very cool script.

For the edges of a Box, I am getting 3 extra direction arrows, for each curve, exterior to the cube, In MoI4Beta.

- Brian

For a clothoid, there are 4 tangent arrows.

Arrow colors different from the curves might be nice?

EDITED: 28 Apr 2020 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
9781.11 In reply to 9781.7 
@Franz - you're welcome, I'm glad it will be useful!

@Wayne - currently there isn't a good way set up for a script to modify the starting "seam point" of a closed curve but I will add in something for that so it will be possible in the next v4 beta.

- 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:  Michael Gibson
9781.12 In reply to 9781.10 
Hi Brian,

re:
> For the edges of a Box, I am getting 3 extra direction arrows, for each curve, exterior to
> the cube, In MoI4Beta.

The arrows have small one unit long lines on them, so they will stick out a little ways past the end of the curve. Right now there isn't any way set up to have just an arrowhead all by itself without a tail on it.


> Arrow colors different from the curves might be nice?

You could do this by setting up a style for the arrows. To do that create a style like this before the first call to UpdateDecorations() :

code:
	var style = moi.geometryDatabase.addStyle();
	var r = 0, g = 255, b = 0;
	style.color = (r << 16) | (g << 8) | b;

	UpdateDecorations( curves, points, dirs, style );


Modify the calls to UpdateDecoration() to pass the style in, and inside UpdateDecorations() when the arrow is created set its styleIndex property like this:

code:
					if ( arrow )
					{
				>>>>		arrow.styleIndex = style.index;
						arrow.setHitTest( false );
						dirs.addObject( arrow );
					}


Then at the bottom below the last call to UpdateDecorations do style.remove();

- 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:  bemfarmer
9781.13 In reply to 9781.12 
Thank you Michael.

I made your arrow color modifications to your script. The modification works well in MoI4beta.

- Brian

I'll delete version 2 in a day or so...since it is your work :-)
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
9781.14 In reply to 9781.13 
Thanks Brian, I'm glad that worked!

> I'll delete version 2 in a day or so...since it is your work :-)

It's fine to leave it, maybe it will help someone else who wants to do that as well.

-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:  bemfarmer
9781.15 In reply to 9781.5 
OrderCurves script uses the color style for the arrows which has been selected before the script is run,

which may be different from the color styles of the curves.

So IMHO, is a better script to use than OrderCurves2 modification.

The color style change code may still be useful in other scripts.

- 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:  wayne hill (WAYNEHILL5202)
9781.16 
Question:

How to programmatically determine an arc object direction (cw/ccw) given the vector dir?

Thank you,
Wayne



code:
	if (moi.majorVersionNumber >= 4) {
			var segs = crv.getSubObjects();
			for (var j = 0; j < segs.length; ++j) {
				var seg = segs.item(j);
				var min = seg.domainMin;
				var max = seg.domainMax;
				var len = max - min;

				for (var k = 0; k < 2; ++k) {
					var t = min + (k / 2 * len);
					var pt = seg.evaluatePoint(t);
					var dir = seg.evaluateTangent(t);

                                         //  ccw boolean > true/false  ?                                        

					var arrow = CreateArrow(pt, dir);
					if (arrow) {
						arrow.setHitTest(false);
						dirs.addObject(arrow);
					}
				}
			}
		}

EDITED: 16 Sep 2020 by WAYNEHILL5202

  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
9781.17 In reply to 9781.16 
Using a right handed helix as an example of the initial curve, say a threaded rod:
Consider an arbitrary point on the helix.
Rotate of the rod, or have the point travel along the helix.
Whether the point is traveling cw or ccw, or..., depends upon the view.
But the curve remains right handed.

- Brian

Maybe use tangent as view direction?

normal and binormal?

I do not understand the cw, ccw question. Maybe some other criterion is needed?

EDITED: 16 Sep 2020 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:  wayne hill (WAYNEHILL5202)
9781.18 In reply to 9781.17 
Hi Brian,

I am working on a project to draw MoI objects to a html canvas.

The html arcs/circles use clockwise and counterclockwise to determine the start and end direction of the arc.

https://www.w3schools.com/tags/canvas_arc.asp

The direction of the arc would also be used within a path for a motion controller. or simple G Code output for CNC machines.

I tried using a cross product from the points. My program logic did not work for some reason. Looking for a rotational cross product for better results.

Thank you,
Wayne
  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
9781.19 In reply to 9781.16 
Hi Wayne, are these arcs all in the world x/y plane (the Top view's plane)?

So the concept of being CW or CCW is with respect to a plane normal, so I think you'll need to incorporate that.

See if this makes sense:


So you have a point on the arc, and the tangent vector. Make a second vector from the point on the arc to the arc's center point.

If you now take the CrossProduct( tangent, towards_center_vector ), that will generate a normal, either the same as your plane normal for the CCW arc, or opposite it for the CW arc. When comparing normals it's not a good idea to test for total equality, due to tiny roundoffs in floating point mathematics you can easily end up with values like 0.00000000000001 instead of 0, so you want to allow some epsilon/tolerance slack in your test.

Something like:

var eps = 1.0e-10;

function IsEqual( x, y )
{
    return Math.abs( x - y ) < eps;
}

function IsEqual( vec1, vec2 )
{
    return IsEqual( vec1.x, vec2.x ) && IsEqual( vec1.y, vec2.y ) && IsEqual( vec1.z, vec2.z );
}

Or another way you can compare normalized vectors is by dotproduct between them which gives the cosine of the angle between them. So something like

function VectorsAreSameDir( vec1, vec2 )
{
return DotProduct( vec1 /*normalized*/, vec2 /*normalized*/ ) > 0.99984769515639123915 (this number is the cosine of 1 degree).
}

Let me know if that doesn't do what you need.

- 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:  Michael Gibson
9781.20 In reply to 9781.16 
Hi Wayne, another way you can determine the direction just using 2D points is to make a 2D triangle and then compute the signed area of the triangle:
https://www.quora.com/What-is-the-signed-Area-of-the-triangle?share=1

It will be a positive number for CCW, and a negative number for CW.

- 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
 

Reply to All Reply to All

 

 
Show messages:  1-20  21