Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
Visual LISP, AutoLISP and General Customization
cancel
Showing results forย 
Showย ย onlyย  | Search instead forย 
Did you mean:ย 

Automation For CNC - Help or hire

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
Anonymous
957 Views, 11 Replies

Automation For CNC - Help or hire

Hello!

 

We use Autocad to help process files for our CNC machine. We use some basic automation scripts already that have really helped but I'm hoping for a more complete solution. I'll outline the script below and would appreciate any guidance or if you reckon it's something you fancy taking on then I'd be happy to discuss price or a donation to a charity or something ๐Ÿ™‚

 

To be applied to all files within a folder

 

1- Import layer states from file on desktop

2- Remove all text

3- Change any 15mm dia holes to 20mm dia

4- Move everything to "BORDER" layer

5- Move 20mm dia circles to "20 hole" layer

6- Move 8mm dia circles to "8 hole" layer

7- Move 5mm dia circles to "5 hole" layer

8- Move 32mm dia circles to "32 hole" layer

9- Move 19mm dia circles to "19 hole" layer

10 - Rotate drawing 90 degrees

11-SAVE

 

Many Thanks! 

 

11 REPLIES 11
Message 2 of 12
Jonathan3891
in reply to: Anonymous

I have a few questions.

1- What type of file contains your layers? An AutoCAD drawing or CSV file?
2- Does removing all text include dimensions and leaders?
3- Does the drawing contain a border or titleblock?
4- Is everything in model space or paper space?

Jonathan Norton
Blog | Linkedin
Message 3 of 12
Anonymous
in reply to: Jonathan3891

Hi Jonathan, please find answers below.

 

1- Autocad drawing (from DXF)

2- The text is just an "MText" object. Only four words.

3- Neither

4- Model Space 

 

I've recently used the Autolisp creator from JefferyPSanders which has meant I can do each task individually. It's just stitching it together and applying to all files.

 

Jake 

Message 4 of 12
Anonymous
in reply to: Jonathan3891

I've just this second figured out how to stitch all these commands together... So now it's just import layer states first then applying it to all files. Any pointers?

Message 5 of 12
Jonathan3891
in reply to: Anonymous

 

Open your DXF file and create a layerstate and export it as a .las file. If you dont know how then follow the steps below.

 

1. Enter command "LAYERSTATE"

2. Click "NEW" and then enter a Name (a description is optional), then press "OK"

3. Click "Export" and save it where ever you want. (In my example I'm saving it to desktop and naming the file "Default.las")

4. Close DXF file

 

Try this code:

(command "-layer" "state" "import" "C:\\Users\\user_name\\Desktop\\default.las" "restore" "default" "" "")

That code works if you want the layer colors to import, other wise you can use this:

 

(layerstate-import "C:\\Users\\jonathan.norton\\Desktop\\default.las" "restore")
T

Jonathan Norton
Blog | Linkedin
Message 6 of 12
Jonathan3891
in reply to: Anonymous

Sorry, double post!


Jonathan Norton
Blog | Linkedin
Message 7 of 12
Anonymous
in reply to: Jonathan3891

Thanks for that! So far so god. Any ideas of how to run the script on every file inside a folder? 

Message 8 of 12
Jonathan3891
in reply to: Anonymous

try this


Jonathan Norton
Blog | Linkedin
Message 9 of 12
Anonymous
in reply to: Jonathan3891

Thank you! This has progressed way further than I expected today. The final touch is to rotate all objects 90 degrees? I can achieve it in the command line just fine but not sure how to translate that onto an autolisp. 

 

 

Command: SELECT
Select objects: all
21 found
Select objects:
Command: ROTATE
Current positive angle in UCS:  ANGDIR=counterclockwise  ANGBASE=0.00
21 found
Specify base point: 0
Specify rotation angle or [Copy/Reference] <0.00>: 90
Message 10 of 12
Jonathan3891
in reply to: Anonymous

Assuming you want to use "0,0" as the base point:

(command "rotate" "all" "" "0,0" "90")

Jonathan Norton
Blog | Linkedin
Message 11 of 12
Anonymous
in reply to: Jonathan3891

Think that's the last bit of the puzzle! Thanks for all your help, I really appreciate it. Don't suppose you've got a script that will save all these files from .DWG to DXF? Not crucial but would be nice! 

Message 12 of 12
Jonathan3891
in reply to: Anonymous

If you want to use a lisp:

(command "dxfout" "" "16")

If you want to use a script use the attachement and change the file type to .scr


Jonathan Norton
Blog | Linkedin

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report