AutoCAD Visual LISP / AutoLISP :: Moving Objects In The X / Y Plane Only
Jul 29, 2013
I want to move a large 3D steel file on top of a 2D architectural background. The ISSUE is that when i move it (in plan view "aka top view") the X,Y coordinates change AND the Z coordinate changes... But, I want the Z coordinate to stay the same . I wrote a LISP file that doesnt seem to work (SEE BELOW):
(defun C:MoveXY (/ PT1 PTB PT2)(setvar "CMDECHO" 0)(setq PT1 (getpoint "
Specify Base Point or [Displacement] Displacement: ")PTB (getpoint "
Specify second point or <use first point as displacement>: ")PT2 (list (car PTB)(cadr PTB)(cddr PT1)))(command "_.MOVE" (SSGET) "" PT1 PT2))
It seems my issue comes when i get to the command line (ssget) seems to mess it all up . How to use the ".Move" command with the (ssget) function?
I find that the command to move objects to a different layers runs very slow in one of the drawing. I want to find out what wrong with the drawing and how to speed things up.
I have a LISP program that batch processes a large number of drawings. One of the step to process each drawing is to change the colors of some objects according to the status of the objects. I do this by moving the objects to a later that has the right color. So far the program only takes 2 to 4 minutes to process each drawing. But the program takes close to 90 minutes to process one specific drawing. I track down the problem has to do with the command that moves the objects to the right layer, like this:
This command takes a very long time to finish, like 40 minutes each time it runs (to move 1200+ objects), and the program needs to run it twice for a total of approximately 80 minutes.
Please note that the drawing itself is not the largest drawing, and it doesn't have the largest number of objects to be moved either. It is close to the top-5 drawings in term of drawing size and the number of objects to be moved. I cannot say that the drawing size or the number of objects to be moved are the cause of the problem.
I tried to "speed up" by moving 200 objects incrementally. That didn't work. I tried to "speed up" by moving 100 objects incrementally and saving the drawing after each 100 objects are moved. That didn't work either; actually the speed is slightly slower than simply moving 1200+ objects all at once.
I don't know what to do. I believe there may be something unusual about that drawing. By the way, the reason why I choose to change color by moving objects to a different layer has to do with the fact that I have found this is the best way so far. I tried to change the color of the objects directly. But I find that the color of some sub-parts of the objects are not changed (because their color is by-layer). That's why I choose to change color by moving objects to a different layer.
How I can check the drawing, any different way to change color that is better.
I am having trouble moving an object a certain distance. The distance is defined by a pre-defined variable. I just can't figure out the syntax for the autolisp command.
Here is the bit of code if written, there is more code not shared here that defines the points for the polyline .
;-- the varaible box_height is defined earlier in the routine
;-- Draw the polyline for the top of the cabinet (command "pline" p1tt P2tt P3tt P4tt P5tt P6tt P7tt P8tt "c")
;-- Assign the new part a variable name (setq cab_toppl (entlast))
;-- Extrude the polyline to make the top of the cabinet (command "extrude" cab_toppl "" cab_intw "0")
;-- Assign the new part a variable name (setq cab_top (entlast))
;-- Rotate the top of the cabinet down to the floor of cabinet
(command "rotate3d" cab_top "" 2 p1tt p2tt 90)
;-- Move the top of the cabinet to the final location
;-- HERE IS THE PART I'M HAVING TROUBLE WITH. ESSENTIALLY ONCE THE PART IS CREATED I'VE NAMED IT CAB_TOP AND AM NOW TRYING TO MOVE IT IN THE Z AXIS THE DISTANCE DEFINED BY THE VARIABLE BOX_HEIGHT WITHOUT USER INPUT
I have been looking around the web to find a quick lsp routine that will take all the xrefs in a drawings and move them back onto layer "xref" or "0" depending on what the design team wants.
The ones I have found don't work or move all the xrefs to separate layers.
I have a lot of attribute blocks in my drawing which i want to move them one by one
so , here is what i want to do :
I have numbers (or texts) in my work area and this numbers also exist in my attribute blocks .. i wanna move my attribute blocks with tag name value reference to my specify area if tag name values are matching with text or numbers in this area .. every block will check my selected tag string and will be move on matching text in my work area.
how to do this programmatically and without modifying the handle of the object,i am trying to do it programmatically (entmod (cons 410 newname)(assoc 410 ... no luck.
(entmakex -ing will modify or create a new handle ctrl-X and then ctrl-V recreates a new handle too ...
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.
I am trying to add a reactor, where if the object i move or copy is s a block of a certain name, then i would like to run update field on the last object (being copied) or the object being moved.
I have been searching for some information on how to pass objects into a function so I can mess with their properties. Somehow I haven't been very successful. Anyway...What I want to do is take two items (light fixtures) and swap their positions on the drawing. It seems like it must be really simple, but I'm just not finding the key puzzle pieces to do it. It seems like if I could figure out how to pull two objects into the function (whether by selecting them and running the function or by selecting them after I run the function) I could very easily save the coordinates of one to variables and then just swap them.
Any way to detect of there are objects currently selected using Autolisp, visual lisp or even VBA. I would like to be able to do something using that as a conditional, so that (assuming the hypothetical variable isSelected is an on/off indicator of whether or not something is selected) I can code something like this:
I need a program to move some selected text to a line something like as extend command but for text objects!
suppose that there is a horizental line (y=constant) or vertical line (x=constant) and some selected text(or other objects), I want a lisp program that move these selected text (or objects) by their "insertion point" to this line.
in other word, if the selected base line is horizental (y=constant) then property of "Y" of all selected text should change to line's "Y"; and if selected base line is vertical (x=constant) then value of "X" of all selected text should match to line's "X" value.
for example, for base vertical line (x=constant) and 3 selected text(or can be any object) result is:
The CADdesigners have asked me if i can make a function that runs through our AutoCAD 2012 MEP model attaching certain predefined classification definitions to ducts, pipes, MVparts etc.
I have used hours searcing for examples / tutorials on how to connect to the MEP objects not finding what i need.
Any Lisp Routine to scale text objects a certain value and have the program actually scale each text object as you pick them.
The change text height using the Properties function does not work for what I need because the objects I need to scale are Mtext objects with Background Mask, and when you use the Properties function to change their text height it messes up the background mask so that you have to select each text entity and stretch the mask area smaller or larger, but if you use the scale function it scales the background mask as well so the background mask coverage is still the same.
I have this code that I wrote years ago that I want to update to select two types of civil3d objects and show them selected with grips on the screen. This function works fine
but if I add the extra object like this which I assume is the wrong syntax i only get the second type of objects. Need correct syntax I should be using for selecting more than one object in an ssget statement.
I have drawings with a lot of polyline objects. I need a routine which will draw multilines by coordinates of vertexes of this polylines. For example, if there is a pline with coordinates 10,10 - 20,20 i want to draw in other layer MLINE with the same coordinates. I know it's should be simple but can not gues how to do it. I've never used LISP before.
I would like converting all objects that has forced linetype to be on a linetype layer.
So if there are objects that have forced linetypes - dashed/hidden/phantom, etc., those entities would be moved to a linetype layer based on their forced linetype. The entities would all be changed to color bylayer, linetype bylayer.
So if there is a rectangle that is sitting on an EQUIPMENT layer, the routine would put that rectangle on a new layer called DASHED and change its forced linetype to BYLAYER.
Lastly, once that's done, the next and final step is to locate a the existing layers with matching linetype - say, OBJECTS with DASHED as a linetype, and merging it to that layer.
I was hoping to use find and replace "#" with broken fields in the drawing. but it will not find the # value that the field creates when it is broken. Is the only way to find a broken field a visual check? or is there another way I am not aware of?
Then I copy that selection set multiple times in a loop. What I would like to do is then rotate (or otherwise modify) the last copied group of items. If I rotate "last" it will only accept the last drawn item, so only one item in the group of copied objects will rotate.
Here is the portion of simple code I am using right now (it's in a loop so all variables with 'Next' are changing each time):