Author Topic: Mmake LISP file to recreate selected objects in new File  (Read 3061 times)

0 Members and 1 Guest are viewing this topic.

mailmaverick

  • Bull Frog
  • Posts: 493
Mmake LISP file to recreate selected objects in new File
« on: September 26, 2014, 05:48:30 AM »
Few years ago I came across a LISP routine which will create a LISP or SCRIPT file to recreate all selected objects in a new file in respective layers, styles etc.

If anyone has it, please share it with me.

Thanks

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: Mmake LISP file to recreate selected objects in new File
« Reply #1 on: September 26, 2014, 07:22:38 AM »
Maybe...

cp.lsp

Code: [Select]
(defun c:cp nil
  (ssget "_:L")
  (command "_.script" (findfile "cp.scr"))
  (princ)
)

cp.scr

Code: [Select]
(vl-load-com)
(setq fn (open "c:/doc.txt" "w"))
(setq k -1)
(while (not (equal (vla-get-activedocument (vlax-get-acad-object)) (vla-item (vla-get-documents (vlax-get-acad-object)) (setq k (1+ k))))))
(princ k fn)
(close fn)
(setq fn nil k nil)
_.copybase
0,0
P

_.new

_.pasteclip
0,0
(vl-load-com)
(setq fn (open "c:/doc.txt" "r"))
(setq k (read (read-line fn)))
(close fn)
(vla-activate (vla-item (vla-get-documents (vlax-get-acad-object)) k))
(defun doc nil
(if (findfile "c:\\doc.txt") (vl-file-delete "c:\\doc.txt"))
(setq doc nil fn nil k nil)
(princ)
)
(alert "Type (doc) at command prompt")
(princ)

Load cp.lsp in acaddoc.lsp and put cp.scr in SFSP of AutoCAD... It works for me, but you should test it...

HTH, M.R.
« Last Edit: November 20, 2014, 03:07:51 PM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

mailmaverick

  • Bull Frog
  • Posts: 493
Re: Mmake LISP file to recreate selected objects in new File
« Reply #2 on: September 26, 2014, 01:05:14 PM »
Dear Marko

When I run the code, it copies the selected objects into a new file instantaneously.
However, I need a LISP / SCRIPT file to be formed when I select objects to be copied.
So that when I send the LISP / SCRIPT file by email to anybody, he can just drag/drop and recreate the objects.


ronjonp

  • Needs a day job
  • Posts: 7529
Re: Mmake LISP file to recreate selected objects in new File
« Reply #3 on: September 26, 2014, 01:40:26 PM »
Why not just send the DWG file ?

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

mailmaverick

  • Bull Frog
  • Posts: 493
Re: Mmake LISP file to recreate selected objects in new File
« Reply #4 on: September 26, 2014, 01:46:31 PM »
Dear Ron

There is some specific reason for that.
And the reason why I am asking for such a file is routine is because I think I have seen i few years ago, which I am not able to find today.
So I though since I have seen it, maybe, other might have also seen it and kept in records.



ronjonp

  • Needs a day job
  • Posts: 7529

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Mmake LISP file to recreate selected objects in new File
« Reply #6 on: September 26, 2014, 02:41:59 PM »
Make sure you get the latest revision of that routine here: http://www.theswamp.org/index.php?topic=31145
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

mailmaverick

  • Bull Frog
  • Posts: 493
Re: Mmake LISP file to recreate selected objects in new File
« Reply #7 on: September 26, 2014, 08:26:35 PM »
Excellent CAB !!!

This is exactly what I was looking for.