Losinski Posted May 11, 2015 Share Posted May 11, 2015 (edited) SOLVED (06/02/2015): Hello, I am looking to move a block and it's surrounding objects all to origin with reference to the block insertion point. When the move command prompts me to "Select a base point," can I somehow choose the insertion point of a block? Thanks, Losinski EDIT 05/12/2015: I'm sorry, I was in a rush when I posted this and should have been more specific. I'm (hopefully) going to make a script that will select and move all, with reference to a blocks insertion point, to 0,0. I need to know if this is possible solely through commands. BIGAL: Yes, this is for three different kinds of titleblocks (NP ISO A0, NP ISO A1, NP ISO A2). I currently have three different scripts, but if they could all be combined into a lsp that would be even better. Ultimately it would need to: Change to paper space (either "Layout" or "Layout1"). Determine which block is being used. Select all in paper space. Move all, with reference to the determined block's insertion point, to 0,0. Delete all outside of the border. The window coordinates for each of the block borders are as follows: NP ISO A0: (-10,10) and (1179,-831) NP ISO A1: (-10,10) and (584,-410) NP ISO A2: (-10,10) and (831,-584) Thanks, Losinski Edited June 2, 2015 by Losinski Original issue resolved. Quote Link to comment Share on other sites More sharing options...
Pablo Ferral Posted May 11, 2015 Share Posted May 11, 2015 Hi Losinski, The answer is yes. You'll need to make sure that you have the 'INSERT' osnap turned on, or use SHIFT+RIGHT CLICK to bring up the temporary osnap overrides. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted May 12, 2015 Share Posted May 12, 2015 Is this a lot of title blocks on layout tabs ? let me know I have a fix. Just run a lsp Quote Link to comment Share on other sites More sharing options...
Losinski Posted May 12, 2015 Author Share Posted May 12, 2015 I'm sorry, I was in a rush when I posted this and should have been more specific. I'm (hopefully) going to make a script that will select and move all, with reference to a blocks insertion point, to 0,0. I need to know if this is possible solely through commands. BIGAL: Yes, this is for three different kinds of titleblocks (NP ISO A0, NP ISO A1, NP ISO A2). I currently have three different scripts, but if they could all be combined into a lsp that would be even better. Ultimately it would need to: Change to paper space (either "Layout" or "Layout1"). Determine which block is being used. Select all in paper space. Move all, with reference to the determined block's insertion point, to 0,0. Delete all outside of the border. The window coordinates for each of the block borders are as follows: NP ISO A0: (-10,10) and (1179,-831) NP ISO A1: (-10,10) and (584,-410) NP ISO A2: (-10,10) and (831,-584) Thanks, Losinski Quote Link to comment Share on other sites More sharing options...
YZ Posted May 18, 2015 Share Posted May 18, 2015 Is the block the only thing in the paperspace? If no, is the block in a unique layer? If you can answer yes to either of these then you can select the block in a script, then set the UCS to that object, move the previous selection from 0,0, switch the UCS back to World before entering the destination coordinates of 0,0. Something like (no testing done yet, just a concept script): -Layer Lock * Unlock Titleblock SelAll Move 0,0 0,0 -Layer Unlock * UCS Object Previous Move Previous 0,0 'ucs WORLD 0,0 Quote Link to comment Share on other sites More sharing options...
BIGAL Posted May 19, 2015 Share Posted May 19, 2015 (edited) here is an example based on a title block ; moves all objects in pspace to 0,0 alignment ; by BIG AL May 2015 (defun c:ABT ( / len plottablist oldnsap ed k ss n xy p1 p2) (PROMPT ".....now moving dwgs....") (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vlax-for lay (vla-get-Layouts doc) (setq plotabs (cons (vla-get-name lay) plotabs)) ) (setq plottablist (acad_strlsort plotabs)) (setq len (length plottablist)) (setq oldsnap (getvar "osmode")) (setvar "osmode" 0) (setq K 0) (repeat len (setq name (nth K plottablist)) (princ name) (if (/= name "Model") (progn (setvar "ctab" name) (setq ss (ssget "_X" (list (cons 0 "INSERT") (cons 2 "NP ISO A1,NP ISO A2,NP ISO A3") ) )) (if (> (setq n (sslength ss)) 1) (alert "you have more than 1 title block") ) (setq en (ssname ss 0)) (setq xy (assoc 10 (entget en))) (setq x (cadr xy)) (setq y (caddr xy)) (setq bname (cdr (assoc 2 (entget en)))) ; needed cdr (cond ((= bname "NP ISO A0")(setq L 1184)(setq w 841)) ;redone to suit OP ((= bname "NP ISO A1")(setq L 841)(setq w 594)) ((= bname "NP ISO A2")(setq L 594)(setq W 420)) ) ; rework out erase window need offsets from title block A1 841x594 (setq p1 (list (setq p1x (- x 10))(setq p1y (- (- Y 10) w)))) (setq p2 (list (setq p2x (+ 10 (+ x L)))(setq p2y (+ 10 Y)))) (vl-cmdf "erase" "all" "remove" "W" P1 P2 "") ; needed "" (command "move" "w" p1 p2 "" (list x y) "0,0") (command "zoom" "E") ) ;end progn ) ; end if ) ; end repeat (setvar "osmode" oldsnap) ) (princ) Edited May 23, 2015 by BIGAL version 2 Quote Link to comment Share on other sites More sharing options...
Losinski Posted May 19, 2015 Author Share Posted May 19, 2015 Thank you for your replies. YZ: The won't be the only thing in paper space. I will need to delete the items that reside outside of the title block border. The block is on a layer called SHEET, along with a couple other blocks that make up the finer details of the overall title block. BIGAL: Your lisp worked very well. However, I still require a few more functions built in. Ideally: The title block selection becomes automatic- would have to choose between three different blocks: "NP ISO A0," "NP ISO A1," AND "NP ISO A2." The items that are outside of the title block window after the move will be deleted. The items that reside outside of the following windows, based on block, would have to be deleted: NP ISO A0: (-10,10) and (1179,-831) NP ISO A1: (-10,10) and (584,-410) NP ISO A2: (-10,10) and (831,-584) Note: Only ONE of these blocks will be present at a time. The following is an example of a simple script for deleting all items outside of the NP ISO A1 block (I tried to wrap CODE tags around the text and they didn't show up). erase all remove window -10,10 831,-584 Also, I know very little about lisp routines. To run the one you posted I used the appload command and had to load it each time I wished to use it. Is it the "defun" line that adds a name to the lisp? I would like to run the routine by the command name "ADJUSTTITLEBLOCK" or "ATB" for short. Thanks again, Losinski Quote Link to comment Share on other sites More sharing options...
BIGAL Posted May 20, 2015 Share Posted May 20, 2015 1 I changed the post to now be a defun you need to Autoload it or add to your appload HIstory so its always there. Search autoload if not sure. 2 I would erase outside first then move much easier as if objects overlap will not work. 3 Will see if I can find time to make it a (cond and look for your block names auto you can add more then etc. It will require making the code into a couple of defuns for simplicity. Quote Link to comment Share on other sites More sharing options...
Losinski Posted May 20, 2015 Author Share Posted May 20, 2015 Okay, thank you BIGAL. That sounds good. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted May 21, 2015 Share Posted May 21, 2015 (edited) I have updated the first code posted and removed from here. Just a suggestion make your title block insert point lower left much easier to work out everything. Edited May 23, 2015 by BIGAL Quote Link to comment Share on other sites More sharing options...
Losinski Posted May 21, 2015 Author Share Posted May 21, 2015 Loaded the lisp and got this error: "Command: ; error: malformed string on input" Thanks for the time you've put in thus far. Quote Link to comment Share on other sites More sharing options...
Spaj Posted May 21, 2015 Share Posted May 21, 2015 Loaded the lisp and got this error: "Command: ; error: malformed string on input" Thanks for the time you've put in thus far. I Think BIGAL may have left for the day... try this... ; moves all objects in pspace to 0,0 alignment (defun c:ABT ( / len plottablist oldnsap ed k ss n xy minxy maxxy) (PROMPT ".....now moving dwgs....") (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vlax-for lay (vla-get-Layouts doc) (setq plotabs (cons (vla-get-name lay) plotabs)) ) (setq plottablist (acad_strlsort plotabs)) (setq len (length plottablist)) (setq oldsnap (getvar "osmode")) (setvar "osmode" 0) (setq K 0) (repeat len (setq name (nth K plottablist)) (princ name) (if (/= name "Model") (progn (setvar "ctab" name) (setq ss (ssget "_X" (list (cons 0 "INSERT") (cons 2 "NP ISO A1,NP ISO A2,NP ISO A3") ) )) (setq n (sslength ss)) (setq en (ssname ss 0)) (setq xy (assoc 10 (entget en))) (setq bname (assoc 2 (entget en))) ; insertion pt (setq xy (assoc 10 el)) (setq xy (list (cadr xy)(caddr xy))) (cond ((= bname "NP ISO A1")(setq p1 "-10,10")(setq P2 "831,-584")) ((= bname "NP ISO A2")(setq p1 "-10,10")(setq P2 "584,410")) ; < missing " ((= bname "NP ISO A3")(setq p1 "-10,10")(setq P2 "410,298")) ) (vl-cmdf "erase" "all" "remove" "W" P1 P2) (command "move" "w" p1 p2 "" xy "0,0") (command "zoom" "E") ) ;end progn ) ; end if (setq K (+ K 1)) (princ k) (setq ss nil) (setq xy nil) ) ; end repeat (setvar "osmode" oldsnap) ) (princ) Quote Link to comment Share on other sites More sharing options...
Losinski Posted May 21, 2015 Author Share Posted May 21, 2015 That lisp loaded correctly Spaj. When run, the drawing zoomed to extents and stopped there. The following is what appeared in the command window. __________________________________________________________________ Command: ABT .....now moving dwgs....Layout1Application ERROR: Invalid type sent as command input move Select objects: w Specify first corner: Command: Command: ABT Unknown command "ABT". Press F1 for help. Command: Command: 0,0 Unknown command "0,0". Press F1 for help. Command: zoom Specify corner of window, enter a scale factor (nX or nXP), or [All/Center/Dynamic/Extents/Previous/Scale/Window/Object] : E Command: 1Layout1Application ERROR: Invalid type sent as command input move Select objects: w Specify first corner: Command: Command: ABT Unknown command "ABT". Press F1 for help. Command: Command: 0,0 Unknown command "0,0". Press F1 for help. Command: zoom Specify corner of window, enter a scale factor (nX or nXP), or [All/Center/Dynamic/Extents/Previous/Scale/Window/Object] : E Command: 2Layout1Application ERROR: Invalid type sent as command input move Select objects: w Specify first corner: Command: Command: ABT Unknown command "ABT". Press F1 for help. Command: Command: 0,0 Unknown command "0,0". Press F1 for help. Command: zoom Specify corner of window, enter a scale factor (nX or nXP), or [All/Center/Dynamic/Extents/Previous/Scale/Window/Object] : E Command: 3Model4Model5Model62199 __________________________________________________________________ Quote Link to comment Share on other sites More sharing options...
BIGAL Posted May 22, 2015 Share Posted May 22, 2015 Thanks Spaj as I said not tested its much easier if we have a sample dwg to test on. Its firday here so will see what I can do over week end. Quote Link to comment Share on other sites More sharing options...
Losinski Posted May 22, 2015 Author Share Posted May 22, 2015 I've attached a test drawing containing a version of the NP ISO A1 block. I can attach one for the NP ISO A2 and NP ISO A0 if need be. Thanks again, Losinski TEST DWG.dwg Quote Link to comment Share on other sites More sharing options...
BIGAL Posted May 23, 2015 Share Posted May 23, 2015 Original code is now updated and seems to be working. Quote Link to comment Share on other sites More sharing options...
Losinski Posted May 25, 2015 Author Share Posted May 25, 2015 Great work. The lisp does exactly what I needed, however it doesn't work for NP ISO A0. This is the error: ".....now moving dwgs....Layout1; error: bad argument type: lselsetp nil" Thanks, Losinski Quote Link to comment Share on other sites More sharing options...
Losinski Posted June 2, 2015 Author Share Posted June 2, 2015 I had a closer look at the program for general typos and found NP ISO A3 instead of NP ISO A0. Changed it in the program and it worked like a charm for all blocks. Thanks again BIGAL for all of your work put into this. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted June 3, 2015 Share Posted June 3, 2015 No worries easy when you have something close. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.