Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

DoNest and label vbs


Recommended Posts

Felix1c,

 

The DoNest() function takes two parameters, the first is the path to a nestlist file (*.ini) that includes nesting parameters and a parts list, the second parameter is a boolean flag set to either show or hide the "regular" nesting parameters dialog prior to each nest call.

 

Below is a typical nestlist that ATP generates on the fly:

 

code:

[PARAMETERS]

VERSION=10.002

TRUESHAPE=NO

ACCUNEST=0

AUTOATTACHCHAINS=NO

EXACTMODE=0

FITPARTINPART=YES

GUILLOTINECUT=NO

IGNOREHOLES=NO

LABELHEIGHT=0.25

LABELHEIGHTAUTO=YES

OPSELECT_INCLUDE_TOOL_RAD=YES

PARTTOPARTDIST=0.1

PROFILETOLERANCE=0.01

RESOLUTION=1

SEPARATEOPPERSHEET=NO

SHEETFILLDIRECTION=_

SHEETTOPARTDIST=0

SORTMAXVACOPS=NO

SORTMAXVACCHAINS=NO

SORTMINTOOLCHG=YES

SORTMODE=2

STARTINGCORNER=1

STOPBETWEENSHEETS=0

FILLALLSHEETS=NO

RESCBOX=1

TOOLPATHS=YES

WORKOFFSETS=0

WORKOFFSETNUMBERING=2

AUTOORIGINS=YES

SHEETTOSHEETDIST=1

ADDLABELS=YES

GRAINDIRECTION=N

QUANTITY=1

[PART1]

VERSION=10.002

PARTID=0

PREVID=-1

PARTNAME=C:DOCUMENTS AND SETTINGSMGMY DOCUMENTSCABINET SOFTWARE DXF FILESKABNXDONUTCASE5_DXF_REPORT_126SS_TOP_0_F.MCX

PARTLABEL=1

LENGTH=1

WIDTH=1

ADDEDRECTANGULAR=NO

USERRECTANGULAR=NO

MINQUANTITY=20

FILLQUANTITY=0

STEPANGLE=0

PRIORITY=1

COMMONTOOL=NO

MIRROR=NO

GRAINDIRECTION=N

CLUSTERMETHOD=7

DELGEO=NO

BASEPOINT-X=0

BASEPOINT-Y=0

MINMAX-X=1

MINMAX-Y=1

CONTOURS_NUMBER=0

NOTES_NUMBER=0

QUANTITY=1

[PART2]

VERSION=10.002

PARTID=0

PREVID=-1

PARTNAME=C:DOCUMENTS AND SETTINGSMGMY DOCUMENTSCABINET SOFTWARE DXF FILESKABNXDONUTCASE5_DXF_REPORT_126SS_TRASH_HOLE_0_F.MCX

PARTLABEL=2

LENGTH=1

WIDTH=1

ADDEDRECTANGULAR=NO

USERRECTANGULAR=NO

MINQUANTITY=20

FILLQUANTITY=0

STEPANGLE=0

PRIORITY=1

COMMONTOOL=NO

MIRROR=NO

GRAINDIRECTION=N

CLUSTERMETHOD=7

DELGEO=NO

BASEPOINT-X=0

BASEPOINT-Y=0

MINMAX-X=1

MINMAX-Y=1

CONTOURS_NUMBER=0

NOTES_NUMBER=0

QUANTITY=1

[PART3]

VERSION=10.002

PARTID=0

PREVID=-1

PARTNAME=C:DOCUMENTS AND SETTINGSMGMY DOCUMENTSCABINET SOFTWARE DXF FILESKABNXDONUTCASE5_DXF_REPORT_126SS_TRASH_HOLE_1_F.MCX

PARTLABEL=3

LENGTH=1

WIDTH=1

ADDEDRECTANGULAR=NO

USERRECTANGULAR=NO

MINQUANTITY=20

FILLQUANTITY=0

STEPANGLE=0

PRIORITY=1

COMMONTOOL=NO

MIRROR=NO

GRAINDIRECTION=N

CLUSTERMETHOD=7

DELGEO=NO

BASEPOINT-X=0

BASEPOINT-Y=0

MINMAX-X=1

MINMAX-Y=1

CONTOURS_NUMBER=0

NOTES_NUMBER=0

QUANTITY=1

[PART4]

VERSION=10.002

PARTID=0

PREVID=-1

PARTNAME=C:DOCUMENTS AND SETTINGSMGMY DOCUMENTSCABINET SOFTWARE DXF FILESKABNXDONUTCASE5_DXF_REPORT_126SS_TRASH_HOLE_2_F.MCX

PARTLABEL=4

LENGTH=1

WIDTH=1

ADDEDRECTANGULAR=NO

USERRECTANGULAR=NO

MINQUANTITY=20

FILLQUANTITY=0

STEPANGLE=0

PRIORITY=1

COMMONTOOL=NO

MIRROR=NO

GRAINDIRECTION=N

CLUSTERMETHOD=7

DELGEO=NO

BASEPOINT-X=0

BASEPOINT-Y=0

MINMAX-X=1

MINMAX-Y=1

CONTOURS_NUMBER=0

NOTES_NUMBER=0

QUANTITY=1

[PART5]

VERSION=10.002

PARTID=0

PREVID=-1

PARTNAME=C:DOCUMENTS AND SETTINGSMGMY DOCUMENTSCABINET SOFTWARE DXF FILESKABNXDONUTCASE5_DXF_REPORT_126SS_TRASH_HOLE_3_F.MCX

PARTLABEL=5

LENGTH=1

WIDTH=1

ADDEDRECTANGULAR=NO

USERRECTANGULAR=NO

MINQUANTITY=20

FILLQUANTITY=0

STEPANGLE=0

PRIORITY=1

COMMONTOOL=NO

MIRROR=NO

GRAINDIRECTION=N

CLUSTERMETHOD=7

DELGEO=NO

BASEPOINT-X=0

BASEPOINT-Y=0

MINMAX-X=1

MINMAX-Y=1

CONTOURS_NUMBER=0

NOTES_NUMBER=0

QUANTITY=1

[sHEET1]

VERSION=10.002

SHEETID=1

SHEETNAME=SHEET #1

LENGTH=96

WIDTH=48

ADDEDRECTANGULAR=YES

ORIGINPOINT-X=0

ORIGINPOINT-Y=0

QUANTITY=0

GRAINDIRECTION=X

DELGEO=NO

BASEPOINT-X=0

BASEPOINT-Y=0

MINMAX-X=96

MINMAX-Y=48

AMAR=YES

CONTOURS-NUMBER=0

NOTES-NUMBER=0

MATERIALNAME=1/2_MDF_material

THICKNESS=0

The above file has 3 main sections, [PARAMETERS], [PART] and [sHEET], [PART] is incrememented for each part in the list as is [sHEET] although I usually only sepecify 1 type of sheet per nest.

Link to comment
Share on other sites

Below is a function I use to create a nestlist on the fly, bare in mind that some object used here are only relative to my NETHook but you should be able to get the gist of whats going on.

 

code:

public MC_RETURN MakeNestlist(ArrayList job)

{

//MC_RETURN result = MC_RETURN.MC_ERROR;

string NestingDefaults = "";

 

//Get nesting values from Nesting Defaults, need to determine if we are inch or metric

bool isMetric = Mastercam.MCRegistry.IsMetric();

 

if ( isMetric )

NestingDefaults = Path.Combine(Mastercam.GUI.GetMCRootDir() , Defines.PATH_NESTING_MM_DEFX);

else

NestingDefaults = Path.Combine(Mastercam.GUI.GetMCRootDir() , Defines.PATH_NESTING_DEFX);

 

if ( !File.Exists(NestingDefaults) )

throw new FileNotFoundException(NestingDefaults);

 

try

{

 

 

//Iterate all materials in arraylist

foreach (Material materials in job )

{

 

//*********************

// [PARAMETERS]

//*********************

//Define a new newlist

NestingParams thisNest = new NestingParams();

 

//thisNest.Accuracy =

 

thisNest.Toolpaths = true;

thisNest.AddLabels = true;

thisNest.label_height_auto = true;

thisNest.WorkOffsets = 0;

thisNest.WorkOffsetNumbering = 2;

thisNest.AutoOrigins = true;

 

switch ( materials.Material_Grain )

{

case Defines.GRAIN_IGNORE:

thisNest.GrainDirection = "N"; //' -- Ignore

break;

 

case Defines.GRAIN_HORIZ:

thisNest.GrainDirection = "X"; //' -- Horizontal (X Axis)

break;

 

case Defines.GRAIN_VERTICAL:

thisNest.GrainDirection = "Y"; //' -- Vertical (Y Axis)

break;

}

 

 

//*********************

// [sHEET]

//*********************

//Define our sheet

NestingParams.NestingSheet newSheet = new NestingParams.NestingSheet();

 

newSheet.length = Convert.ToDouble(materials.Material_Length);

newSheet.width = Convert.ToDouble(materials.Material_Width);

newSheet.quantity = Convert.ToInt32(materials.Material_Quantity);

newSheet.Thickness = Convert.ToDouble(materials.Material_Thickness);

newSheet.MaterialName = materials.Material_Name;

newSheet.quantity = Convert.ToInt32(materials.Material_Quantity);

 

//Add the sheet to the list

thisNest.AddSheet(newSheet);

 

int i = 0;

 

//Get all parts for this material

ArrayList currParts = materials.Parts();

 

//Iterate each part in this material

foreach (Part theseParts in currParts)

{

if (theseParts.Front.ToUpper() == "B")

{

// Do not nest these parts as they are flagged for

// secondary (back side) operations

materials.AddBackFacePart(theseParts);

materials.HasBackFaceParts = true;

}

else

{

i += 1;

//*********************

// [PART]

//*********************

NestingParams.NestingPart newPart = new NestingParams.NestingPart();

 

newPart.part_name = theseParts.MCX;

newPart.part_label = i.ToString();

newPart.priority = Convert.ToInt32(theseParts.Priority);

newPart.Quantity = Convert.ToInt32(theseParts.Quantity);

newPart.mirror = theseParts.Mirror;

 

//Store the item number

theseParts.NestItemNumber = i.ToString();

 

//Make sure this part is allowed to rotate but contains no blockdrilling ops

if (theseParts.AllowRotate && !theseParts.BlockDrilled)

{

switch (materials.Material_Grain)

{

case Defines.GRAIN_IGNORE:

newPart.grain_direction = "N";

newPart.step_angle = 90;

break;

 

case Defines.GRAIN_HORIZ:

newPart.grain_direction = "X";

newPart.step_angle = 180;

break;

 

case Defines.GRAIN_VERTICAL:

newPart.grain_direction = "Y";

newPart.step_angle = 180;

break;

}

}

else

newPart.step_angle = 0;

 

//Add the part to the list

thisNest.AddPart(newPart);

 

}

}

//Write out the file e.g. CPath to unique material folderNestlist.ini

thisNest.WriteToFile(materials.Nestlist);

 

 

}

 

}

catch ( Exception ex )

{

throw ex;

}

 

 

return MC_RETURN.MC_NOERROR;

 

}


Link to comment
Share on other sites
  • 3 years later...

Hi,

 

I tried the VB Script example program above to implement DoNest VBScript function. I get a warning message box:

 

Box title: Nesting vX4 r22.5

Warning - Nesting not available in this product

 

 

But when I'm doing it manually (XForm/Geometry Nesting...), it works.

 

Someone can give me some help on that

 

Thanks

 

Jaouad

Link to comment
Share on other sites

Hi Mike,

 

Thank you for your reply.

 

I could not run this VB Script because I got a box message error:

 

Box title: Nesting vX4 r22.5

Warning - Nesting not available in this product

 

Could you please tell me what is the problem^

 

Thanks

 

Jaouad

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...