hosyn Posted August 18, 2014 Posted August 18, 2014 (edited) (defun c:test ( / ss ) (if (setq ss (ssget "_:L")) (command "_.move" ss "" "_non" '(0. 0. 0.) "_non" '(-20 0. 0.));; <<destination change to (19,10,0) ) (princ) ) If we wanna move that in specification point (10,10,0) how we can modify it?? Edited August 18, 2014 by hosyn Quote
Cylis0509 Posted October 23, 2015 Posted October 23, 2015 Simplest way: (defun c:test ( / ss ) (if (setq ss (ssget "_:L")) (command "_.move" ss "" "_non" '(0. 0. 0.) "_non" '(-20 0. 0.)) ) (princ) ) Lee Mac, I was hoping you could help me out. I have some code to move an object based on input from the user. It works well, but the code is not pretty. As you will see it does the move command in three parts. I was wondering how can I combine all the X Y Z values into one move? Also if you know a way to let the user select more than one option and/or give the ability to type ALL. I would like it to move even locked layers. This is to be used for coordinate shifting. The users knows how far in the x and y direction the entire drawing needs to move. Thank you in advance. (defun C:test5 ( / sn x xd yd zd newxd newyd newzd selobj) (SETVAR "CMDECHO" 0) (setq sn (getvar "osmode")) (command "osnap" "near") (setq x 0) (princ "\nMoves an object in the X, Y and Z directions") (setq xd (getstring "\n Enter the amount of change in the X direction: ")) (setq yd (getstring "\n Enter the amount of change in the Y direction: ")) (setq zd (getstring "\n Enter the amount of change in the Z direction: ")) (setq newxd (strcat xd ",0")) (setq newyd (strcat "0," yd)) (setq newzd (strcat "0,0," zd)) (while (= x 0) (setq selobj (entsel "\nSelect object to move: ")) (if (/= selobj nil) (progn (command "move" selobj "" "0,0" newxd) (command "move" selobj "" "0,0" newyd) (command "move" selobj "" "0,0,0" newzd) )) (if (= selobj nil)(setq x 1)) ) ) Quote
Lee Mac Posted October 23, 2015 Posted October 23, 2015 Certainly possible, but why not just use the standard MOVE command? Command: MOVE Select objects: Specify base point or [Displacement] <Displacement>: 0,0 Specify second point or <use first point as displacement>: [color=red]1[/color],[color=blue]2[/color],[color=green]3[/color] Here, red is the displacement in the x-direction, blue is the displacement in the y-direction, green is the displacement in the z-direction. Quote
Cylis0509 Posted October 23, 2015 Posted October 23, 2015 Certainly possible, but why not just use the standard MOVE command? Command: MOVE Select objects: Specify base point or [Displacement] <Displacement>: 0,0 Specify second point or <use first point as displacement>: [color=red]1[/color],[color=blue]2[/color],[color=green]3[/color] Here, red is the displacement in the x-direction, blue is the displacement in the y-direction, green is the displacement in the z-direction. Oh I defiantly could. But this was specifically asked for by a user. I just figured I would see if it could be done. Quote
Lee Mac Posted October 23, 2015 Posted October 23, 2015 Oh I defiantly could. But this was specifically asked for by a user. I just figured I would see if it could be done. I would suggest teaching the user how to use the MOVE command. Or as an even easier option, use the Displacement option of the MOVE command so that you needn't specify the origin as a base point. Quote
Cylis0509 Posted October 23, 2015 Posted October 23, 2015 I would suggest teaching the user how to use the MOVE command. Or as an even easier option, use the Displacement option of the MOVE command so that you needn't specify the origin as a base point. Agreed and will do. But for my own education; how would you pass values obtained from user input to a command such as the move command. Quote
Lee Mac Posted October 23, 2015 Posted October 23, 2015 how would you pass values obtained from user input to a command such as the move command. Obtain numerical values using getreal and then pass a point list to the MOVE command (as opposed to using a string); however, since you are prompting the user for X, Y & Z values, you might as well prompt for a point. Quote
Cylis0509 Posted October 23, 2015 Posted October 23, 2015 AAAHHH.. ok great! I will try it out. Thank you so much! Quote
Hsanon Posted October 28, 2015 Posted October 28, 2015 Is it possible to stretch instead of move ???? for example, if we take a crossing window around a door opening and stretch it over fixed distances ( say 200 mm ) ???? Quote
Emmanuel Delay Posted July 14, 2017 Posted July 14, 2017 Sure, it works just as well for stretch as for move. use "_.stretch" instead of "_.move" ------- For whomever might be interested ... I wrote a MOVE command that works opposite to the normal version. First I select the destination point, then the source point, then I select the objects. ;; Stretch To From (defun c:stf ( / ss to from) (setq to (getpoint "\nPick destination point") from (getpoint "\nPick source point") ) (princ "\nSelect objects") (if (setq ss (ssget "_:L")) (command "_.stretch" ss "" "_non" from "_non" to) ) (princ) ) ;; Move To From (defun c:mtf ( / ss to from) (setq to (getpoint "\nPick destination point") from (getpoint "\nPick source point") ) (princ "\nSelect objects") (if (setq ss (ssget "_:L")) (command "_.move" ss "" "_non" from "_non" to) ) (princ) ) Why? Example: I need to place 100 RJ45 jacks in a big building. They are blocks with attributes, pre inserted (in a row somewhere outside the building), the attributes are pre set. They need to be placed with precision, in corners, under the middle of a desk, next to a door, ... It's easy to find block with the correct number, but takes pan/zoom to pick the destination point. Also, only when I know the orientation of the corner at the the destination point, I know which baseboint of the block to pick. So I have to zoom to the destination point first anyway. I might as well pick that point first. Why stretch instead of move? There is a cable, represented by a line, between the jack and a patch panel (or rack, or floorbox, ...) Quote
BlackBox Posted July 14, 2017 Posted July 14, 2017 Why? Example: I need to place 100 RJ45 jacks in a big building. They are blocks with attributes, pre inserted (in a row somewhere outside the building), the attributes are pre set. They need to be placed with precision, in corners, under the middle of a desk, next to a door, ... It's easy to find block with the correct number, but takes pan/zoom to pick the destination point. Also, only when I know the orientation of the corner at the the destination point, I know which baseboint of the block to pick. So I have to zoom to the destination point first anyway. I might as well pick that point first. Why stretch instead of move? There is a cable, represented by a line, between the jack and a patch panel (or rack, or floorbox, ...) ... Or you could just use two Viewports (tiled vertically, side-by-sdie?), and have one zoomed into the desired location, the other on the RJ45 jacks, no? Cheers Quote
Emmanuel Delay Posted July 14, 2017 Posted July 14, 2017 Yes, there are many tricks I can think of (Viewports being one). But thinking back at times when using the move command really bugged me ... the problem was that move has the wrong order or operations (not always, just some specific tasks). And I consider writing a 5 line function (of which I copied most of it from this topic) less of a problem than finding workarounds, or having this command that bugs me a little (or a lot). Quote
luisupulkka Posted November 12, 2021 Posted November 12, 2021 On 7/14/2017 at 4:05 PM, Emmanuel Delay said: Sure, it works just as well for stretch as for move. use "_.stretch" instead of "_.move" ------- For whomever might be interested ... I wrote a MOVE command that works opposite to the normal version. First I select the destination point, then the source point, then I select the objects. ;; Stretch To From (defun c:stf ( / ss to from) (setq to (getpoint "\nPick destination point") from (getpoint "\nPick source point") ) (princ "\nSelect objects") (if (setq ss (ssget "_:L")) (command "_.stretch" ss "" "_non" from "_non" to) ) (princ) ) ;; Move To From (defun c:mtf ( / ss to from) (setq to (getpoint "\nPick destination point") from (getpoint "\nPick source point") ) (princ "\nSelect objects") (if (setq ss (ssget "_:L")) (command "_.move" ss "" "_non" from "_non" to) ) (princ) ) Why? Example: I need to place 100 RJ45 jacks in a big building. They are blocks with attributes, pre inserted (in a row somewhere outside the building), the attributes are pre set. They need to be placed with precision, in corners, under the middle of a desk, next to a door, ... It's easy to find block with the correct number, but takes pan/zoom to pick the destination point. Also, only when I know the orientation of the corner at the the destination point, I know which baseboint of the block to pick. So I have to zoom to the destination point first anyway. I might as well pick that point first. Why stretch instead of move? There is a cable, represented by a line, between the jack and a patch panel (or rack, or floorbox, ...) This inspired me to make simple (better ways to do welcomed) version for copybase with deselection feature which is built-in in my previous used drawing program Cadmatic. Sharing this is my way to thank for whole forum for its existness . If someone is interested I have trimmed also other general commands. Eg. previous selection set saved without need to do anything with that set because I often press esc at "wrong" time and current selected set did not save in previous selected set (for my Cadmatic-built-in affected finger ). (this might be off-topic so please moderate message if needed cause first time here) ;; for deselect objects after copying (defun C:C ( / ss from); (setq ss (ssget "_I")) (cond ((null ss) ; if objects not yet selected (princ "\nSelect objects") (setq ss (ssget "_:L")) (setq from (getpoint "\nSpecify base point:") ) (command "_.copybase" from ss "") (princ) ); cond1 ends ;(command "copybase" pause pause "") ((> (sslength ss) 0) ; if objects ready selected (setq from (getpoint "\nSpecify base point:") ) (command "_.copybase" from ss "") (princ) ); cond2 ends ;(command "copybase" pause pause "") ); cond ends (ai_deselect); deselect objects ); defun CopyBaseDeselect.lsp 1 Quote
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.