Use Script pro 2.0 to move single solid object in multiple dwg files to new position

Use Script pro 2.0 to move single solid object in multiple dwg files to new position

philip_revell6WEZ4
Community Visitor Community Visitor
275 Views
2 Replies
Message 1 of 3

Use Script pro 2.0 to move single solid object in multiple dwg files to new position

philip_revell6WEZ4
Community Visitor
Community Visitor

New to forum and trying to learn more about scripting for mundane tasks.   Does anyone have any good examples or sources on the web for learning scripting in autocad to simply

 

1) open a dwg 

2) sel all solids  (only one in each file)

3) move to a specific coordinate (x,y,z)

4) qsave 

5) close the file 

6) Open the next dwg file and repeat the above

 

I was able to do this using script pro 2.0 some time ago but lost my script and I'm trying to relearn what I did

 

Any help most appreciated

0 Likes
276 Views
2 Replies
Replies (2)
Message 2 of 3

Moshe-A
Mentor
Mentor

@philip_revell6WEZ4  hi,

 

to make it clear, when you say select all solids you mean

 

2d SOLID    objects ?

3d SOLIDS objects ?

 

Moshe

 

 

0 Likes
Message 3 of 3

Sea-Haven
Mentor
Mentor

The script would be the same as your manual commands so write them down. The srcipt will be something like.

 

open dwg1
(load "mymovelisp.lsp")
open dwg2
(load "mymovelisp.lsp")
open dwg3
(load "mymovelisp.lsp")

 

Mymovelisp.lsp

(setvar 'ctab "Model")
(command "zoom" "E")
(setq ss (ssget "x" '((0 . "3DSOLID"))))
(setq obj (ssname ss 0))
(setq cen (vlax-get (vlax-ename->vla-object obj) 'centroid))
(command "move" ss "" cen "123,456")
(command "close" "Y")

NOT TESTED

0 Likes