Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

LISP .scr : Hi LIPS Masters Can we copy data DWG/DXF to other DWG/DXF

puneet_psc
Explorer
Explorer

LISP .scr : Hi LIPS Masters Can we copy data DWG/DXF to other DWG/DXF

puneet_psc
Explorer
Explorer

Dear Masters,
The script/LISP is new for me, so please help me to write a script to copy all data from one DWG/DXF to another DWG/DXF.

Thank you 

Reply
Accepted solutions (1)
689 Views
7 Replies
Replies (7)

handjonathan
Community Manager
Community Manager

Hi @puneet_psc 

Thanks a lot for posting your question to the forums!   Take a look at this link from @Lee_Mac 

We look forward to hearing back from you with more information so we can help you as a community! 



Jonathan Hand


Industry Community Manager | AEC (Architecture & Building)

0 Likes

Sea-Haven
Mentor
Mentor

What about insert other dwg into current dwg ?

puneet_psc
Explorer
Explorer

👉What about insert other dwg into current dwg ?

@Sea-Haven Yes, It will be useful for me


for more clarification: - I am using software for exporting Isometric Drawings in DXF format but intelligent or colored backing sheet/title block  can't export from that software, so I am planning to export DXF without title block/backing sheet after that will use bath file to insert the title block in all .dxf with the help of LISP

Thank you @Sea-Haven 


0 Likes

puneet_psc
Explorer
Explorer

Yes, I want to attach the file, Please share some script, It will be a great help for me @Sea-Haven 

LISP Master Please help me here to share a script that can help me to attach another dwg

0 Likes

Sea-Haven
Mentor
Mentor

When you type insert a option is to look via explorer for another dwg then insert it.

 

Why not open other dwg then just select what you want Ctrl+c, close dwg, should be back in original dwg, then just Ctrl+V. No code required.

 

If it is something you want in every project then add the block to your DWT ie template dwg, you can purge out unused blocks.

0 Likes

komondormrex
Advisor
Advisor
Accepted solution

since the topic is almost similar to the adjacent one, and as far as i understand the input data, also minding not it is apprentice, i am placing this take to test.

 

 

;*******************************************************************************************************************************************

(defun check_layer_exist (layer_name odbx_object / )
		(if (vl-catch-all-error-p (vl-catch-all-apply 'vla-item (list (vla-get-layers odbx_object) layer_name)))
			(vla-add (vla-get-layers odbx_object) layer_name)
		)
		layer_name
)

;*******************************************************************************************************************************************

(defun get_filename (extension / output_name filename)
	(setq output_name (strcat (vlax-get (vla-get-activedocument (vlax-get-acad-object)) 'path) "\\A3_"
							  (vl-filename-base (vlax-get (vla-get-activedocument (vlax-get-acad-object)) 'name))
					  )
	)
	(if (type acet-ui-getfile)
			(setq filename (acet-ui-getfile (strcat "Enter " (strcase extension) " filename") output_name extension "" 1))
			(setq filename (getfiled "Enter CSV filename" output_name extension 1))
	)
	(if (= "" filename) nil filename)
)

;*******************************************************************************************************************************************

(defun create_dummy_dwg_file (/ dummy_dwg_filename acad_dbx_object)
	(setq dummy_dwg_filename (strcat (vla-get-tempfilepath (vla-get-files (vla-get-preferences (vlax-get-acad-object)))) "Dummy.dwg"))
	(if (findfile dummy_dwg_filename) (vl-file-delete dummy_dwg_filename))
	(setq acad_dbx_object (vlax-create-object (strcat "objectdbx.axdbdocument." (substr (getvar 'acadver) 1 2))))
	(vl-catch-all-apply 'vla-open (list acad_dbx_object dummy_dwg_filename))
	(vla-saveas acad_dbx_object dummy_dwg_filename)
	(vlax-release-object acad_dbx_object)
	dummy_dwg_filename
)

;*******************************************************************************************************************************************

(defun c:partial_dwg_A3_export (/ odbx_to_objects_list llc_list ruc_list min_x min_y max_x max_y boundary_rectangle boundary_center
							      selection_center dummy_full_name acad_dbx_object odbx_objects_list screen_size boundary_center
							   )
	(if (minusp (vlax-get (vla-get-system (vla-get-preferences (vlax-get-acad-object))) 'singledocumentmode))
			(vla-set-singledocumentmode (vla-get-system (vla-get-preferences (vlax-get-acad-object))) :vlax-false)
	)
	(setq odbx_to_objects_list (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex (ssget))))))
	(foreach object odbx_to_objects_list
		(vla-getboundingbox object 'llc 'ruc)
		(setq llc_list (append llc_list (list (vlax-safearray->list llc)))
			  ruc_list (append ruc_list (list (vlax-safearray->list ruc)))
		)
	)
	(setq min_x (apply 'min (mapcar 'car llc_list))
		  min_y (apply 'min (mapcar 'cadr llc_list))
		  max_x (apply 'max (mapcar 'car ruc_list))
		  max_y (apply 'max (mapcar 'cadr ruc_list))
		  boundary_rectangle (vlax-invoke (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
										  'addlightweightpolyline
										  (list min_x min_y min_x max_y max_x max_y max_x min_y min_x min_y)
							 )
		  boundary_center (vla-addpoint (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
									    (vlax-3d-point (list (* 0.5 (+ min_x max_x)) (* 0.5 (+ min_y max_y))))
						  )
	)
	(vla-put-color boundary_rectangle 1)
	(vla-put-color boundary_center 1)
	(setq selection_center (vlax-get boundary_center 'coordinates))
	(vla-erase boundary_rectangle)
	(vla-erase boundary_center)
	(setq dwg_full_name (get_filename "dwg")
		  dummy_full_name (create_dummy_dwg_file)
		  acad_dbx_object (vlax-create-object (strcat "objectdbx.axdbdocument." (substr (getvar 'acadver) 1 2)))
	)
	(vla-open acad_dbx_object dummy_full_name)
	(setq graphics_boundary (vla-addlightweightpolyline
								(vla-get-modelspace acad_dbx_object)
				 				(vlax-safearray-fill (vlax-make-safearray vlax-vbdouble '(0 . 11)) (list 5 5 5 589 634.3 589 634.3 113 835 113 835 5))
							)
		  text_boundary (vla-addlightweightpolyline
		  					(vla-get-modelspace acad_dbx_object)
				 			(vlax-safearray-fill (vlax-make-safearray vlax-vbdouble '(0 . 7)) (list 634.3 113 634.3 589 835 589 835 113))
						)
	)
	(vla-put-closed graphics_boundary :vlax-true)
	(vla-put-closed text_boundary :vlax-true)
	(setq odbx_objects_list
		  (vlax-invoke (vla-get-database (vla-get-activedocument (vlax-get-acad-object)))
		  			  'copyobjects
		  			   odbx_to_objects_list
		  			   (vla-get-modelspace acad_dbx_object)
		  )
	)
	(vla-put-layer graphics_boundary (check_layer_exist "AM_2" acad_dbx_object))
	(vla-put-layer text_boundary "AM_2")
	(vlax-map-collection (vla-get-textstyles acad_dbx_object)
		'(lambda (textstyle)
			(if (null (vl-catch-all-error-p (vl-catch-all-apply 'vla-item (list (vla-get-textstyles (vla-get-activedocument (vlax-get-acad-object))) (vla-get-name textstyle)))))
					(vla-put-fontfile textstyle (vla-get-fontfile (vla-item (vla-get-textstyles (vla-get-activedocument (vlax-get-acad-object))) (vla-get-name textstyle))))
			)
		 )
	)
	(foreach object odbx_objects_list
		(vla-move object (vlax-3d-point selection_center) (vlax-3d-point '(319.65 297)))
	)
	(setq screen_size (getvar 'screensize))
	(vla-put-height (vla-item (vla-get-viewports acad_dbx_object) 0) 594.0)
	(vla-put-width (vla-item (vla-get-viewports acad_dbx_object) 0) (* (car screen_size) (/ 584.0 (cadr screen_size))))
	(vla-put-center (vla-item (vla-get-viewports acad_dbx_object) 0)
					(vlax-safearray-fill (vlax-make-safearray vlax-vbdouble '(0 . 1))
										 (list 420 297)
					)
	)
	(vla-saveas acad_dbx_object dwg_full_name)
	(vlax-release-object acad_dbx_object)
	(princ (strcat "\nSelected entities have been written as \"" dwg_full_name "\""))
	(princ)
)

;*******************************************************************************************************************************************

 

 

puneet_psc
Explorer
Explorer

Thank you everyone for your kind support, 

0 Likes