Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Script for moving the drawing in multiple drawings.

12 REPLIES 12
Reply
Message 1 of 13
rudrasree
1827 Views, 12 Replies

Script for moving the drawing in multiple drawings.

QT : 1 . I  am looking for a script to move the drawing such that the left bottom corner is placed at 0,0  without any manual intervension. This is to done for all the files in a particular folder.

 

QT : 2   In the same script file I want one block to be inserted also in each drawing. the block is placed in the network drive . so how to copy the path after putting the insert command.  I tried -insert;  but it is not working how can i give the path in script file.

 

pls guide I am a beginner in the programming side ... trying to learn

12 REPLIES 12
Message 2 of 13

Is the corner you want at 0,0 always in the same location in your drawings?

 

(command "-insert" "C:\\Folder\\SubFolder\\block.dwg" "0,0,0" "1" "1" "0")

 

You can copy and paste your network location just make sure you change \ to \\.  Set your Filedia to 0 also.

Message 3 of 13

... If not at the same location in all drawings, you may need to extract lowest X, Y coordinate from BoundingBox iteration of ModelSpace Objects.

 

The only other way to programmatically determine a relatively consistent starting point, would be to Zoom Extents, then extract from Polar calculation of ViewCtr, and ScreenSize variables (again, not exactly surgical precision, but relatively consistent presumption).

 

Cheers



"How we think determines what we do, and what we do determines what we get."

Message 4 of 13
pbejse
in reply to: BlackBox_


@BlackBoxCAD wrote:

... If not at the same location in all drawings, you may need to extract lowest X, Y coordinate from BoundingBox iteration of ModelSpace Objects.

 

Cheers


I second that. Smiley Happy

Message 5 of 13
BlackBox_
in reply to: pbejse


@pbejse wrote:

@BlackBoxCAD wrote:

... If not at the same location in all drawings, you may need to extract lowest X, Y coordinate from BoundingBox iteration of ModelSpace Objects.

 

Cheers


I second that. Smiley Happy


Cheers, pdejse. 



"How we think determines what we do, and what we do determines what we get."

Message 6 of 13
rudrasree
in reply to: rudrasree

Can you please guide me how to extract the bounding box in auto cadd....

Message 7 of 13
Kent1Cooper
in reply to: rudrasree


@rudrasree wrote:

QT : 1 . I  am looking for a script to move the drawing such that the left bottom corner is placed at 0,0  without any manual intervension. ....


No need to calculate the bounding box of the drawn content [you'd need to look at it for every object, and combine the lower-left-most X and Y coordinates of them all].  Use the EXTMIN System Variable instead.

 

(command "_.move" "_all" "" (getvar 'extmin) "0,0")

 

That should work in any drawing as you open it, but if you do it after any kind of editing, include a REGEN first, because the EXTMIN System Variable [as well as EXTMAX] swells outward when anything is added beyond its current value, but it doesn't shrink back inward when something is erased or changed, until a Regen or a Zoom All or Zoom Extents [I think those are the ones -- look up EXTMIN in the System Variables list in Help].

Kent Cooper, AIA
Message 8 of 13
pbejse
in reply to: Kent1Cooper


@Kent1Cooper wrote:
No need to calculate the bounding box of the drawn content [you'd need to look at it for every object, and combine the lower-left-most X and Y coordinates of them all].  Use the EXTMIN System Variable instead.

(command "_.move" "_all" "" (getvar 'extmin) "0,0")

 


Nice one Kent. 

 

In addition to that

 

(defun c:mk nil
  (command "_layer" "on" "*" "_thaw" "*" "_unlock" "*" "")
  (command "_.move" "_all" "" (getvar 'extmin) "0,0")
  (command "_layerp")
)

 

I was thinking more of a VL approach , this is another case of Script versus ODBX.

 

Message 9 of 13
Kent1Cooper
in reply to: Kent1Cooper


@Kent1Cooper wrote:
....Use the EXTMIN System Variable....

 

(command "_.move" "_all" "" (getvar 'extmin) "0,0")

....


In addition, it would probably be a good idea to make sure Object Snap can't throw off the results, either by setting OSMODE to 0 first or by just applying None Osnap to the Move displacement points:

 

(command "_.move" "_all" "" "_none" (getvar 'extmin) "_none" "0,0")

Kent Cooper, AIA
Message 10 of 13
Kent1Cooper
in reply to: Kent1Cooper


@Kent1Cooper wrote:
....

(command "_.move" "_all" "" (getvar 'extmin) "0,0")

....


And another thing....

 

That will only do the current space, whether Model space or the current layout/tab in Paper space.  So if you might have both kinds, and you want this to happen in all spaces, you would need to step through and do it in each one -- that can also be automated.

Kent Cooper, AIA
Message 11 of 13
pbejse
in reply to: Kent1Cooper


@Kent1Cooper wrote:
That will only do the current space, whether Model space or the current layout/tab in Paper space.  So if you might have both kinds, and you want this to happen in all spaces, you would need to step through and do it in each one -- that can also be automated.

Only thing is, you may need to add another routine to re-position the contents of a "viewport" if the entities on Model space and the viewport itself does move.

 

Or the user can do it manually that is.

 

Message 12 of 13
rudrasree
in reply to: Kent1Cooper


@Kent1Cooper wrote:

@Kent1Cooper wrote:
....Use the EXTMIN System Variable....

 

(command "_.move" "_all" "" (getvar 'extmin) "0,0")

....


In addition, it would probably be a good idea to make sure Object Snap can't throw off the results, either by setting OSMODE to 0 first or by just applying None Osnap to the Move displacement points:

 

(command "_.move" "_all" "" "_none" (getvar 'extmin) "_none" "0,0")


Thanks for the post

Can you  u please guide me why you have put _none.

I could understand move; all by getting extmin to 0,0 but what does this "none" mean.

I am only an end user so not familier with much detail...

once again thanks for the post.

Message 13 of 13
Kent1Cooper
in reply to: rudrasree


@rudrasree wrote:
....

Thanks for the post

Can you  u please guide me why you have put _none.

I could understand move; all by getting extmin to 0,0 but what does this "none" mean.

....


It's an object-snap mode, just like ENDpoint or MIDpoint or INTersection.  It ensures that if you have running object-snap modes turned on, the Move command will not "find" some nearby location that you do not want it to use, such as an Endpoint or an Intersection, for either the start or end of the displacement.  If the routine were made to turn object snap off entirely, those could be omitted.  But when you do it that way, it's better to save the OSMODE System Variable value first, then set it to 0, and finally, reset it to the saved value at the end.  In a routine such as this that only uses a couple of points to which object snap could possibly be applied, it takes far less code to just leave OSMODE as it is, and turn object snap off for each location.

Kent Cooper, AIA

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost