Search the Community
Showing results for tags 'entity'.
Found 5 results
accessing entity in a codes windows selection set
maerfl posted a topic in AutoLISP, Visual LISP & DCLHello I'm not able to figure out how to easily access the first entity of a slection set created with coded windows selection. I want to read out coodinates of the first point of 2 different objects which are "grabed" in a coded windows selection set. One polyline, one line. Then I want to copy the line from it's first point as basepoint to the first point of the polyline. Advanced I would like to copy it to all the other points of the polyline too. So it would be further more interesting to know how to access (read out the coordinates of) the second, the third and so on point of an object...using visual lisp. The following code is using first a pick up of the object where the line should be copied to and a static coordinate for the basepoint of the line instead of a read out coodinate: (vl-load-com) (setq sel1 (ssget "_w" '(-2 -2) '(115 10))) (setq e (car (entsel))) (setq topoint (vlax-curve-getStartPoint e)) (command "_.COPY" sel1 "" "0,0" topoint)
Sort & number entities by clicking - LISP request (to improve laser cut efficiency)
daveacad posted a topic in AutoLISP, Visual LISP & DCLHi people! I'm looking for some help: I need to cut plexiglas with laser. The form, drawed with Autocad, come with many circles and arcs. Know someone a routine or lisp able to click entities to reorder the sortment? And, second, it will be wonderful to add a progressive number to the entities to visually control the sortment of them! (I hope the question I made is clear. My english is very poor). Ciao, Daveacad
Way of thinking
ripuz posted a topic in AutoLISP, Visual LISP & DCLHi, I want to prevent a layer from being plotted and I have found a few ways to do this but which way is the best? 1. (command "_.-layer" "p" "n" "LAYERNAME" "") 2. (defun PlotLayer2 (layerName bool / en output) (if (setq en (tblobjname "LAYER" layerName)) (progn (entmod (subst (cons 290 (if bool 1 0)) (assoc 290 (entget en)) (entget en))) (setq output T) ) ) output ) 3. (defun PlotLayer3 (layerName bool / acadObj doc layers layer output) (setq acadObj (vlax-get-acad-object)) (setq doc (vla-get-activedocument acadObj)) (setq layers (vla-get-layers doc)) (setq layer (vl-catch-all-apply 'vla-item (list layers layerName))) (if (not (vl-catch-all-error-p layer)) (progn (vla-put-plottable layer (if bool :vlax-true :vlax-false)) (vlax-release-object layer) (setq output T) ) ) (mapcar 'vlax-release-object (list layers doc acadObj)) output ) I know that it doesn´t play a big role in this example, but which is the best programming technique theoretically? Is it needed to release the objects in PlotLayer3? Thanks in advance!
Get point of when there are no entities selected.
Lee Chu Chu posted a topic in AutoLISP, Visual LISP & DCLI have this code: (setq PT1 (getpoint)) (setq PT2 (getpoint PT1)) (command "LINE" PT1 PT2) (command) (setq obj1 (entget (entlast))) (setq ent (car (nentsel "\nSelect Entity: \n"))) (cond ((/= ent nil) (setq obj2 (entget ent)) (command "chamfer" obj ent) ) ((= ent nil) (setq PT3 (getpoint ent)) (command "LINE" PT2 PT3) ) ) ) Its supposed to be able to draw a line when if there is no entity it draws the line up till that point where I tried to select the entity. However when I execute this code, it will state that I have an inappropriate data type. How should I modify the code to be able to draw the line from the last point to the point of which I tried to select an entity if an entity doesn't exist at that particular point?
Custom transformation and entity types
aps posted a topic in AutoLISP, Visual LISP & DCLHi! First of all sorry for my poor english. I'm total beginner in AutoLISP, I work mostly with GIS software and data, but i have to manage the following problem. I've recieved a big DWG file which is containing around 30000 entities with various entity types and several layers. Everything is in a custom local coordinate system, and I have to transform it into an other coordinate system. I only have the transformation equations, so I create my first AutoLISP file based on codes I've found on this and other forums: (defun c:customtransform() (if (setq ss (ssget "_:L")) (repeat (setq i (sslength ss)) (setq entitylist (entget (ssname ss (setq i (1- i))))) (setq obj (ssname ss i)) (setq new nil) (repeat (setq j (length entitylist)) (if (= 10 (car (nth (setq j (1- j)) entitylist))) (progn (setq x (cadr (nth j entitylist)) y (caddr (nth j entitylist)) ) (setq y (+ (+ (+ 0 332134.109) (* 0.40008331 x)) (* 0.59595102 y))) (setq x (+ (+ (+ 0 1087.012) (* 0.59595102 x)) (* -0.40008331 y))) (setq new (cons (list 10 x y) new)) ) (setq new (cons (nth j entitylist) new)) ) ) (entdel obj) (entmake new) ) ) (princ) ) It mostly does what I want, but there are 3 problems: 1. It does not move objects with MLINE and REGION entity type. 2. It transforms only a part of the LINE and 3D FACE entities. For example: one node of a LINE entity moves into the new position and the other node remains in the original position, so the result is a long line, with one node in the correct position and one node in the old position. 3. It works perfectly with most of the TEXT entities, but there are some TEXTs that remain in their original positions, and I can't find out what is the difference between the "working" texts and the "non-working" texts. Any advice how to fix the problems mentioned above? Thanks for any help!