CNC

CNC

Francisco_Melo
Enthusiast Enthusiast
1,124 Views
7 Replies
Message 1 of 8

CNC

Francisco_Melo
Enthusiast
Enthusiast

Good Morning!
There are some drawings that I receive in dxf, and I have to prepare them for the CNC machine to receive them. But for that I have to make a few small changes to the drawings one by one.
I would like to know if someone can help me or direct me to the correct website.
What I have to do is
Create Layer with color:
3 - color 3
4 - color 4
5 - color 5
6 - color 6
CUT - color 7

After:
join all the lines and convert to closed polyline and put in the CUT layer.
Search for all circumferences of radius 3 and put in the layer 3.
Search for all circumferences of radius 4 and put in the layer 4.
Search for all circumferences of radius 5 and put in the layer 5.
Search for all circumferences of radius 6 and put in the layer 6.

Finally record in dxf and close the drawing.

Thanks

0 Likes
1,125 Views
7 Replies
Replies (7)
Message 2 of 8

maratovich
Advisor
Advisor

If the segments cannot be closed?
Give an example file.

---------------------------------------------------------------------
Software development
Automatic creation layouts and viewport. Batch printing drawings from model.
www.kdmsoft.net
0 Likes
Message 3 of 8

Francisco_Melo
Enthusiast
Enthusiast

The files

0 Likes
Message 4 of 8

CADaSchtroumpf
Advisor
Advisor

Hi,

In new drawing copy and paste this

((lambda ( / f_exe ShlObj Folder FldObj Out_Fld file_scr file_bat)
	(vl-load-com)
	(setq f_exe (findfile "accoreconsole.exe"))
	(setq
		ShlObj (vla-getinterfaceobject (vlax-get-acad-object) "Shell.Application")
		Folder (vlax-invoke-method ShlObj 'BrowseForFolder 0 "" 0)
	)
	(vlax-release-object ShlObj)
	(if Folder
		(progn
			(setq
				FldObj (vlax-get-property Folder 'Self)
				Out_Fld (vlax-get-property FldObj 'Path)
			)
			(vlax-release-object Folder)
			(vlax-release-object FldObj)
		)
	)
	(setq file_scr (open (strcat (getvar "ROAMABLEROOTPREFIX") "support\\update.scr") "w"))
	(write-line "((lambda ( \\ js) (foreach n '(\"3\" \"4\" \"5\" \"6\" \"CUT\")(if (not (tblsearch \"LAYER\" n))(command \"_.layer\" \"_m\" n \"_color\" (if(eq n \"CUT\") 7 (atoi n)) n \"\")))(setq js (ssget \"_X\" '((0 . \"LINE\"))))(cond(js(command \"_.change\" js \"\" \"_properties\" \"_layer\" \"CUT\" \"\")(command \"_.pedit\" \"_multiple\" js \"\" \"_yes\" \"_join\" \"0.0\" \"\")))(foreach n '(\"3\" \"4\" \"5\" \"6\")(setq js (ssget \"_X\" (list '(0 . \"ARC,CIRCLE\") (cons 40 (atof n)))))(cond(js(command \"_.change\" js \"\" \"_properties\" \"_layer\" n \"\"))))))" file_scr)
	(write-line "(command \"_.audit\" \"_Yes\")" file_scr)
	(write-line "(command \"_.-purge\" \"_Regapps\" \"*\" \"_No\")" file_scr)
	(write-line "(command \"_.-purge\" \"_All\" \"*\" \"_No\")" file_scr)
	(write-line "(command \"_.saveas\" \"_DXF\" \"16\" \"\" \"_Yes\")" file_scr)
	(write-line "(command \"_.close\" \"_No\")" file_scr)
	(close file_scr)
	(setq file_bat (open (strcat (getvar "ROAMABLEROOTPREFIX") "support\\update.bat") "w"))
	(write-line (eval (read "(strcat \"set accoreexe=\" \"\\\"\" f_exe \"\\\"\")")) file_bat)
	(write-line (eval (read "(strcat \"set source=\" \"\\\"\" Out_Fld \"\\\"\")")) file_bat)
	(write-line (eval (read "(strcat \"set script=\" \"\\\"\" (getvar \"ROAMABLEROOTPREFIX\") \"support\\\\update.scr\" \"\\\"\")")) file_bat)
	(write-line "FOR /f \"delims=\" %%f IN ('dir /b \"%source%\\\*.dxf\"') DO %accoreexe% /i \"%source%\\%%f\" /s %script%" file_bat)
	(close file_bat)
	(startapp (strcat (getvar "ROAMABLEROOTPREFIX") "support\\update.bat"))
	(princ"\Job finished")
	(prin1)
))

Select your folder where you have your DXF and script run in accore console.

Message 5 of 8

Francisco_Melo
Enthusiast
Enthusiast

Hi, thanks for your quick response. But it's not working.
it will be because the original file is in .DXF

Here is the original file.

0 Likes
Message 6 of 8

CADaSchtroumpf
Advisor
Advisor

If your file are DWG as your original file try this

((lambda ( / f_exe ShlObj Folder FldObj Out_Fld file_scr file_bat)
	(vl-load-com)
	(setq f_exe (findfile "accoreconsole.exe"))
	(setq
		ShlObj (vla-getinterfaceobject (vlax-get-acad-object) "Shell.Application")
		Folder (vlax-invoke-method ShlObj 'BrowseForFolder 0 "" 0)
	)
	(vlax-release-object ShlObj)
	(if Folder
		(progn
			(setq
				FldObj (vlax-get-property Folder 'Self)
				Out_Fld (vlax-get-property FldObj 'Path)
			)
			(vlax-release-object Folder)
			(vlax-release-object FldObj)
		)
	)
	(setq file_scr (open (strcat (getvar "ROAMABLEROOTPREFIX") "support\\update.scr") "w"))
	(write-line "((lambda ( \/ js) (foreach n '(\"3\" \"4\" \"5\" \"6\" \"7\" \"CUT\")(if (not (tblsearch \"LAYER\" n))(command \"_.layer\" \"_m\" n \"_color\" (if(eq n \"CUT\") 7 (if(eq n \"7\") 2 (atoi n))) n \"\")))(setq js (ssget \"_X\" '((0 . \"LINE\"))))(cond(js(command \"_.change\" js \"\" \"_properties\" \"_color\" \"_bylayer\" \"_layer\" \"CUT\" \"\")(command \"_.pedit\" \"_multiple\" js \"\" \"_yes\" \"_join\" \"0.0\" \"\")))(foreach n '(\"3\" \"4\" \"5\" \"6\" \"7\")(setq js (ssget \"_X\" (list '(0 . \"ARC,CIRCLE\") (cons 40 (* 0.5 (atof n))))))(cond(js(command \"_.change\" js \"\" \"_properties\" \"_color\" \"_bylayer\" \"_layer\" n \"\"))))))" file_scr)
	(write-line "(command \"_.layer\" \"_set\" \"0\" \"\")" file_scr)
	(write-line "(command \"_.audit\" \"_Yes\")" file_scr)
	(write-line "(command \"_.-purge\" \"_Regapps\" \"*\" \"_No\")" file_scr)
	(write-line "(command \"_.-purge\" \"_All\" \"*\" \"_No\")" file_scr)
	(write-line "(command \"_.saveas\" \"_DXF\" \"16\" \"\")" file_scr)
	(write-line "(command \"_.close\" \"_No\")" file_scr)
	(close file_scr)
	(setq file_bat (open (strcat (getvar "ROAMABLEROOTPREFIX") "support\\update.bat") "w"))
	(write-line (eval (read "(strcat \"set accoreexe=\" \"\\\"\" f_exe \"\\\"\")")) file_bat)
	(write-line (eval (read "(strcat \"set source=\" \"\\\"\" Out_Fld \"\\\"\")")) file_bat)
	(write-line (eval (read "(strcat \"set script=\" \"\\\"\" (getvar \"ROAMABLEROOTPREFIX\") \"support\\\\update.scr\" \"\\\"\")")) file_bat)
	(write-line "FOR /f \"delims=\" %%f IN ('dir /b \"%source%\\\*.dWg\"') DO %accoreexe% /i \"%source%\\%%f\" /s %script%" file_bat)
	(close file_bat)
	(startapp (strcat (getvar "ROAMABLEROOTPREFIX") "support\\update.bat"))
	(princ"\Job finished")
	(prin1)
))
Message 7 of 8

Francisco_Melo
Enthusiast
Enthusiast

Thanks in advance,
I've been researching and trying to do it myself, but I'm failing at something. Does it have a solution.

Thanks

 

(defun c:CNC ()
(command "Change" "all" "" "properties" "ltype" "Bylayer" "")
(command "Change" "all" "" "properties" "color" "Bylayer" "")
(command "Change" "all" "" "properties" "lweight" "Bylayer" "")
(command "pedit" "multiple" "all" "" "join" "" "")
(command "-layer" "new" "CUT" "")
(command "change" "all" "" "properties" "CUT" "" "")
(setq ss (ssget "X" '((0 . "CIRCLE"))))
(repeat (setq i (sslength ss))
(setq ent (entget (ssname ss (setq i (1- i))))
dia (* 2 (cdr (assoc 40 ent)))
color (fix dia)
)
(if (not (<= 1 color 255))
(setq color 7)
)
(or
(tblsearch "layer" (setq layer (strcat "" (rtos dia 2 1))))
(vl-cmdf "_.-layer" "_M" layer "_C" color layer "")
)
(entmod (subst (cons 8 layer)(assoc 8 ent) ent))
)
)
(command "-purge" "all" "" "no")
(command "-purge" "all" "" "no")
(command "-purge" "all" "" "no")
(command "zoom" "extents")
(command "regen")
(command "+saveas" "dxf" "2018dxf" "" "16" "" "Yes")
(princ))

0 Likes
Message 8 of 8

Anonymous
Not applicable

Yes this file work in CNC. As I am working in CNC machining service this really helps thanks.

0 Likes