Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

RectCoordinates ( pieceA ; pieceB ; materialA ; materialB )

Featured Replies

Name & Parameters: [color:red][big] RectCoordinates ( pieceA ; pieceB ; materialA ; materialB ) [/big]

Description: Returns the coordinates of rectangles (with dimensions pieceA x pieceB,) that can be cut from an area of materials (with dimensions materialA x materialB.)

This is designed to be used by the xmChart plugin to generate a graphic representation of how to cut the most pieces from the material.

Sample Input:

RectCoordinates(12;12;15;25)

Results:

AddRect(0; 0; 25; 15; gray)

AddRect( 0;0;12;12;white)

AddFrame(0;0;12;12;1;black)

AddRect( 12;0;12;12;white)

AddFrame(12;0;12;12;1;black)

Recursive: no

Formula:

//RectCoordinates ( pieceA ; pieceB ; materialA; materialB )



/*

Returns the coordinates of rectangles (with dimensions pieceA x pieceB,) that can be cut from an area of materials (with dimensions materialA x materialB.)



This is designed to be used by the xmChart plugin to generate a graphic representation of how to cut the most pieces from the material. 

Coordinates start from the top, left.  

The string returned is in the form: 



OpenDrawing()¶

AddRect( 0;0;12;12;white)¶

AddFrame(0;0;12;12;1;black)¶

AddRect( 0;12;12;12;white)¶

AddFrame(0;12;12;12;1;black)¶

CloseDrawing()



CFs Required: RectCoordinatesSub(), RectCount(), and DrawRect().



7-29-2006

By Mike Hackett

*/



Let(

[

  pieceLongSide = Max(pieceA; pieceB);

  pieceShortSide = Min(pieceA; pieceB);

  materialLongSide = Max(materialA; materialB);

  materialShortSide = Min(materialA; materialB)

];



Case(materialA>0 and materialB >0 and pieceA > 0 and pieceB > 0; //Ensures values are all entered

  "AddRect(0; 0; " & materialLongSide & "; " & materialShortSide & "; gray)¶"&

  Case((materialA * materialB) / (pieceA * pieceB) < 125; //Ensures it won't time out on a recursive call limit

    RectCoordinatesSub( pieceLongSide; pieceShortSide; materialLongSide; materialShortSide; 0; 0 );

    "//Too many pieces to calculate."

    )

  )

) 

Required Functions: RectCoordinatesSub()

RectCount()

DrawRect()

Author(s):) Ender

Date: 07/29/06

Credits: Based on the discussion in this thread: http://www.fmforums.com/forum/showtopic.php?tid/170643/

Disclaimer:

FM Forums does not endorse or warrantee these files are fit for any particular purpose. Do not post or distribute files without written approval from the copyright owner. All files are deemed public domain unless otherwise indictated. Please backup every file that you intend to modify.

RectanglePieces.fp7.zip

  • 1 year later...
  • Author

Here's an updated version of the demo file which adds compatibility with xmChart version 3.x.

One thing that this version of xmChart does differently is return the chart directly as a result of the external call. This means it can be used in an auto-enter calc to refresh the chart.

The custom functions in this demo are still the same.

RectanglePieces2.fp7.zip

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.