Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
Home
Help
Login
Register
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
Help with a lisp: PASTEORIG in a new document
« previous
next »
Print
Pages: [
1
] |
Go Down
Author
Topic: Help with a lisp: PASTEORIG in a new document (Read 1938 times)
0 Members and 1 Guest are viewing this topic.
PM
Guest
Help with a lisp: PASTEORIG in a new document
«
on:
February 28, 2020, 03:40:25 AM »
Hi i need help with a lisp code. I want to select everything (only the oplen layers not the close or frozen) from one drawing and paste them with original coordinates in a new document from specific location. I try this code but when open the new document return to the previous and don't paste the selected part
Code - Auto/Visual Lisp:
[Select]
(
defun
c:test
(
)
(
ssget
"_x"
'
(
(
410
.
"Model"
)
)
)
(
command
"copyclip"
(
ssget
"_x"
'
(
(
410
.
"Model"
)
)
)
)
(
setq
acApp
(
vlax-get-acad-object
)
)
(
setq
acDocs
(
vla-get-documents
acApp
)
)
(
vla
-
open
acDocs
"c:
\\
myfile
\\
test
\\
test.dwg"
)
(
command
"PASTEORIG"
""
)
(
princ
)
)
Thanks
Logged
Tutulisper
Mosquito
Posts: 11
Re: Help with a lisp: PASTEORIG in a new document
«
Reply #1 on:
February 28, 2020, 03:50:33 AM »
Hi,you can use "copyobjects " to the new document
this is the code maybe it useful.
Code - Auto/Visual Lisp:
[Select]
(
defun
c:tes
(
/
app docs doc objects ss i n sslist
)
(
setq
app
(
vlax-get-acad-object
)
)
(
setq
doc
(
vla-get-activedocument
app
)
)
(
setq
docs
(
vla-get-documents
app
)
)
(
setq
ss
(
ssget
(
list
(
cons
410
(
Getvar
"CTAB"
)
)
)
)
)
(
setq
n
(
sslength
ss
)
i
0
)
(
repeat
n
(
setq
sslist
(
append
sslist
(
list
(
vlax
-
ename
->
vla-object
(
ssname
ss i
)
)
)
)
)
(
setq
i
(
1+
i
)
)
)
(
setq
objects
(
vlax
-
make
-
safearray
vlax-vbObject
(
cons
0
(
1-
n
)
)
)
)
(
vlax-safearray-fill
objects sslist
)
(
setq
doc_new
(
vla-add
docs
"acad.dwt"
)
)
(
vla-copyobjects
doc objects
(
vla-get-modelspace
doc_new
)
)
(
vla-saveas
doc_new
"e:
\\
drawing.dwg"
)
(
vla
-
close
doc_new
)
(
princ
)
)
«
Last Edit: February 28, 2020, 04:22:02 AM by Tutulisper
»
Logged
PM
Guest
Re: Help with a lisp: PASTEORIG in a new document
«
Reply #2 on:
February 28, 2020, 07:53:27 AM »
I have the same layers in the drawing and the same layers in the dwt but i use different colors in the drawing than in the dwt. When i run the code i miss the colors in the dwt. I want the insert drwing to take the colors from the dwt. Any option ?
Logged
PM
Guest
Re: Help with a lisp: PASTEORIG in a new document
«
Reply #3 on:
February 28, 2020, 01:18:46 PM »
the first way if better to me ,but i have probleme with the paste in original coordinates.Any option?
Code - Auto/Visual Lisp:
[Select]
(
defun
c:test
(
)
(
ssget
"_x"
'
(
(
410
.
"Model"
)
)
)
(
command
"copyclip"
(
ssget
"_x"
'
(
(
410
.
"Model"
)
)
)
)
(
setq
acApp
(
vlax-get-acad-object
)
)
(
setq
acDocs
(
vla-get-documents
acApp
)
)
(
vla
-
open
acDocs
"c:
\\
myfile
\\
test
\\
test.dwg"
)
(
command
"PASTEORIG"
""
)
(
princ
)
)
Thanks
Logged
PM
Guest
Re: Help with a lisp: PASTEORIG in a new document
«
Reply #4 on:
February 28, 2020, 04:25:57 PM »
Ok i test again Tutulisper and works perfect. I want to add a layon command and a zoom extend command but is not working because when open the new document paste the drawing ,and return to the first drawing and do the lay on and zoom extend in the first drawing. Can any pne help ?
Code - Auto/Visual Lisp:
[Select]
(
defun
c:tes
(
/
app docs doc objects ss i n sslist
)
(
setq
app
(
vlax-get-acad-object
)
)
(
setq
doc
(
vla-get-activedocument
app
)
)
(
setq
docs
(
vla-get-documents
app
)
)
(
setq
ss
(
ssget
(
list
(
cons
410
(
Getvar
"CTAB"
)
)
)
)
)
(
setq
n
(
sslength
ss
)
i
0
)
(
repeat
n
(
setq
sslist
(
append
sslist
(
list
(
vlax
-
ename
->
vla-object
(
ssname
ss i
)
)
)
)
)
(
setq
i
(
1+
i
)
)
)
(
setq
objects
(
vlax
-
make
-
safearray
vlax-vbObject
(
cons
0
(
1-
n
)
)
)
)
(
vlax-safearray-fill
objects sslist
)
(
setq
doc_new
(
vla-add
docs
"acad.dwt"
)
)
(
vla-copyobjects
doc objects
(
vla-get-modelspace
doc_new
)
)
(
vla-saveas
doc_new
"e:
\\
drawing.dwg"
)
(
vla
-
close
doc_new
)
(
princ
)
)
Thanks
Logged
Tutulisper
Mosquito
Posts: 11
Re: Help with a lisp: PASTEORIG in a new document
«
Reply #5 on:
February 28, 2020, 09:17:57 PM »
I think lisp can not accitve the new document, so zoom the document have no idea ,the lisp reactor maybe can do it but i can not use it.
this code is only copy the objects to the new document.
you can modify the "lock" "freeze" state。
Code - Auto/Visual Lisp:
[Select]
(
defun
c:tes
(
/
app docs doc objects ss i n sslist objlay insyslay insyslayobj
)
(
setq
app
(
vlax-get-acad-object
)
)
(
setq
doc
(
vla-get-activedocument
app
)
)
(
setq
docs
(
vla-get-documents
app
)
)
(
setq
modelspaceobjs
(
vla-get-ModelSpace
doc
)
)
(
setq
docs
(
vla-get-documents
app
)
)
(
vlax-for
obj modelspaceobjs
(
setq
objlay
(
Vla-Get-Layer
obj
)
)
(
setq
insyslay
(
tblobjname
"layer"
objlay
)
)
(
setq
insyslayobj
(
Vlax
-
Ename
->
Vla-Object
insyslay
)
)
; if the layer is on then add to the list
(
if
(
and
(
=
-
1
(
vlax-get
insyslayobj 'layeron
)
)
;layer is on
(
=
0
(
vlax-get
insyslayobj 'lock
)
)
;layer is not lock
(
=
0
(
vlax-get
insyslayobj 'freeze
)
)
;;layer is not freeze
)
(
progn
(
setq
sslist
(
append
sslist
(
list
obj
)
)
)
)
)
)
(
if
(
>
(
length
sslist
)
1
)
(
progn
(
setq
objects
(
vlax
-
make
-
safearray
vlax-vbObject
(
cons
0
(
1-
(
length
sslist
)
)
)
)
)
(
vlax-safearray-fill
objects sslist
)
(
setq
doc_new
(
vla-add
docs
"acad.dwt"
)
)
(
vla-copyobjects
doc objects
(
vla-get-modelspace
doc_new
)
)
(
vla-saveas
doc_new
"e:
\\
drawing.dwg"
)
(
vla
-
close
doc_new
)
)
)
(
princ
)
)
«
Last Edit: February 28, 2020, 09:58:22 PM by Tutulisper
»
Logged
PM
Guest
Re: Help with a lisp: PASTEORIG in a new document
«
Reply #6 on:
February 29, 2020, 08:50:26 AM »
Hi Tutulisper.I try yourr code but my layer ar stay off. Is any other way to do zoom extend and layon the new document ?
Logged
Tutulisper
Mosquito
Posts: 11
Re: Help with a lisp: PASTEORIG in a new document
«
Reply #7 on:
February 29, 2020, 09:41:44 AM »
can use scr to do it
Code - Auto/Visual Lisp:
[Select]
(
command
"._script"
scrfilename
)
in the scrfile like this code
open
"e:
\d
rawing.dwg"
ZOOM E qsave
close
Logged
PM
Guest
Re: Help with a lisp: PASTEORIG in a new document
«
Reply #8 on:
February 29, 2020, 11:54:23 AM »
When the copy the object in the new document return to the previus file. Is any way to go back in the new document and zoom extend and lay on?
Logged
Tutulisper
Mosquito
Posts: 11
Re: Help with a lisp: PASTEORIG in a new document
«
Reply #9 on:
February 29, 2020, 08:47:39 PM »
Use lisp do it is difficult i have no idea.
you can use vba or c# very easy.
Logged
PM
Guest
Re: Help with a lisp: PASTEORIG in a new document
«
Reply #10 on:
March 02, 2020, 02:39:37 PM »
Thanks for your time.I am not using script files ot vba. I will search more from a solution through lisp.
Logged
Print
Pages: [
1
] |
Go Up
« previous
next »
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
Help with a lisp: PASTEORIG in a new document