|
|
| Zeile 16: |
Zeile 16: |
| | === Python version: === | | === Python version: === |
| | <code> | | <code> |
| − | [https://www.google.com/search?client=safari&rls=en&q=cambam.pixelmaker.eu/pages/phocadownload/scripten/mop-automate.py&ie=UTF-8&oe=UTF-8 mop.automate.py] | + | [https://www.google.com/search?client=safari&rls=en&q=cambam.pixelmaker.eu/pages/phocadownload/scripten/mop-automate.py&ie=UTF-8&oe=UTF-8 mop.automate.py]</code> |
| | + | |
| | === VB-Script Version: === | | === VB-Script Version: === |
| − | </code>
| + | <code>[https://www.google.com/search?client=safari&rls=en&q=cambam.pixelmaker.eu/pages/phocadownload/scripten/mop-automate.vbs&ie=UTF-8&oe=UTF-8 mop.automate.vbs]</code> |
| − | <code>' | |
| − | ' mop-automate.vbs
| |
| − | '
| |
| − | sub main
| |
| − | | |
| − | ' TO CHANGE...
| |
| − | dim source_file = "C:\CamBam\cbfiles\aluskids.dxf"
| |
| − | dim out_filename = "C:\dump\test.cb"
| |
| − | | |
| − | ' Open a source file
| |
| − | ' note: the second parameter '1' opens the file synchronously rather than in a worker thread
| |
| − | CamBamUI.MainUI.OpenFile(source_file,1)
| |
| − | | |
| − | ' The 'doc' global variable is always the CADFile before any file opens,
| |
| − | ' so we create a new varialbe pointing to the newly opened active file...
| |
| − | dim newdoc = CamBamUI.MainUI.ActiveView.CADFile
| |
| − |
| |
| − | ' draw some shapes...
| |
| − | dim poly = new Polyline()
| |
| − | poly.Add(8,5,0)
| |
| − | poly.Add(22,5,0)
| |
| − | poly.Add(25,15,0)
| |
| − | poly.Add(15,25,0)
| |
| − | poly.Add(5,15,0)
| |
| − | poly.Closed=True
| |
| − | newdoc.Add(poly)
| |
| − |
| |
| − | dim circle = new Circle()
| |
| − | circle.Center = new Point3F(-30,15,0)
| |
| − | circle.Diameter=15
| |
| − | newdoc.Add(circle)
| |
| − | | |
| − | ' set any machining options required...
| |
| − | newdoc.MachiningOptions.PostProcessor = "Mach3-CutViewer"
| |
| − | newdoc.MachiningOptions.FastPlungeHeight = 0.1
| |
| − | | |
| − | ' Select All...
| |
| − | CamBamUI.MainUI.ActiveView.SelectAllVisibleGeometry()
| |
| − |
| |
| − | ' Convert to polylines...
| |
| − | PolylineUtils.PolyLinesConvert(CamBamUI.MainUI.ActiveView)
| |
| − | ' The gui operation runs in a worker process, so wait for the
| |
| − | ' thinking message to disapear...
| |
| − | while not CamBamUI.MainUI.ActiveView.CurrentEditMode is nothing
| |
| − | app.Sleep(1)
| |
| − | end while
| |
| − |
| |
| − | ' Edit - Join
| |
| − | PolylineUtils.JoinPolyLines(CamBamUI.MainUI.ActiveView,0.001)
| |
| − | ' wait for the thinking message to disapear...
| |
| − | while not CamBamUI.MainUI.ActiveView.CurrentEditMode is nothing
| |
| − | app.Sleep(1)
| |
| − | end while
| |
| − | | |
| − | ' create a profile mop
| |
| − | ' Use all the drawing objects from the first layer...
| |
| − | ' dim profile = new CamBam.CAM.MOPProfile(newdoc,newdoc.Layers(0).Entities.ToArray())
| |
| − | ' Use all the drawing objects from the last layer...
| |
| − | ' dim profile = new CamBam.CAM.MOPProfile(newdoc,newdoc.Layers(newdoc.Layers.Count-1).Entities.ToArray())
| |
| − | ' Use all the drawing objects from a layer with a specific name...
| |
| − | dim profile = new CamBam.CAM.MOPProfile(newdoc,newdoc.Layers("LAYER_03").Entities.ToArray())
| |
| − | | |
| − | ' Set the profile style property...
| |
| − | profile.Style = "cutout"
| |
| − | | |
| − | ' Other properties are based on the generic CBValue class
| |
| − | ' Some examples of how these properties should be set...
| |
| − | ' Note: CBValue(of type) syntax not working in current release
| |
| − | ' as extra .dlls need to be referenced in the VB script host.
| |
| − | ' user alternative syntax...
| |
| − | | |
| − | dim td = profile.ToolDiameter
| |
| − | td.SetValue(0.8)
| |
| − | profile.ToolDiameter = td
| |
| − | | |
| − | dim io = profile.InsideOutside
| |
| − | io.SetValue(CamBam.CAM.InsideOutsideOptions.Inside)
| |
| − | profile.InsideOutside = io
| |
| − | | |
| − | ' add the machine op to the drawing...
| |
| − | CamBamUI.MainUI.InsertMOP(profile)
| |
| − | | |
| − | ' save the current drawing...
| |
| − | newdoc.Save(out_filename)
| |
| − | | |
| − | ' create g-code output
| |
| − | CamBam.CAM.CAMUtils.GenerateGCodeOutput(view)
| |
| − | | |
| − | end sub
| |
| | </code> | | </code> |