Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/18/2021 in all areas

  1. If you are talking about getting all elements in the list whose first element in each sublist matches the supplied second argument, I'll give you an A+ and I would also go the same approach you've taken. My personal preference, I would use equal instead of = to account for any tolerances just in case AutoLISP gets glitchy (it won't happen with INT, but just in case, I can get really pedantic). I suppose the original post was requesting for both the removal of duplicates and extracting by value. I only assumed that he wanted to delete the non-duplicates since that seemed to hold the criterion, so I wrote that function.
    2 points
  2. Beaten to it... I was about to say the same, copy the items, create a selection set from them and carry on as before using the new set. Below is pretty much the same as above, should work (defun c:SPDXFOUT (/ pt ss objekte text Name) (if (and (princ "\n Select objects to copy to 0,0 ") (setq ss (ssget "_:L")) (setq pt (getpoint "\n Enter base point: ")) ) (progn (setq LastEnt (entlast)) ;add this to delete anything after this point. (command "_copy" ss "" "_NONE" pt "_NONE" '(0.0 0.0 0.0)) (if (setq en (entnext LastEnt)) (while en (setq ss1 (ssadd en ss1)) (setq en (entnext en)) ) ) ) ) (if (and (sssetfirst nil (ssget "_P")) (setq text (if (setq text (car(nentsel "\nget text ")))(setq text (cdr(assoc 1 (entget text))))) Name (getfiled "Export save as: " (strcat (getvar "DWGPREFIX")(if text (strcat text ".dxf") "")) "dxf" 1) ) ) (command "dxfout" Name "V" "2007" "O" ss1 "" "") ) (command "._erase" "_object" ss1 "") ) Oh, I changed the LISP name, just don't like using the same as an actual command that's all
    1 point
  3. I thought you just wanted to erase the copied items? You can build a new selection set of the copied items by changing the 2nd part of what i added. (defun c:DXFOUT (/ pt SS SS1 text Name) (if (and (princ "\n Select objects to copy to 0,0 ") (setq ss (ssget "_:L")) (setq pt (getpoint "\n Enter base point: ")) ) (progn (setq LastEnt (entlast)) (command "_.Copy" SS "" "_non" PT "_non" '(0.0 0.0 0.0)) (setq SS1 (ssadd)) (if (setq en (entnext LastEnt)) (while en (ssadd en SS1) (setq en (entnext en)) ) ) ) ) ;(command "_.zoom" "_object" SS1 "") ; would zoom to copied items (setq text (car (nentsel "\nSelect Text: ")) text (cdr (assoc 1 (entget text))) Name (getfiled "Export save as: " (strcat (getvar "DWGPREFIX") (if text (strcat text ".dxf") "")) "dxf" 1) ) (if Name (command "dxfout" Name "V" "2007" "O" SS1 "" "") ;dxfout copied items SS1 ) (command "_.Erase" SS1 "") ;erase copies items SS1 ;(command "_.zoom" "v") (princ) ) This will create a selection set of SS1 of the copied entity's
    1 point
  4. Use this when exploding stuff and add them back to a Selection set. modified it to delete the items copied. way it works. Think of the drawing as a list of items and when working on a drawing anything you create or manipulate gets put to the end of that list "last entity". So you bookmark of the current "last entity" before you create anything new "copy" that then gets added to the end of the list. the while command is saying delete anything on the drawings list but stop at the bookmarked last entity. (defun c:DXFOUT (/ pt ss objekte text Name) (if (and (princ "\n Select objects to copy to 0,0 ") (setq ss (ssget "_:L")) (setq pt (getpoint "\n Enter base point: ")) ) (progn (setq LastEnt (entlast)) ;add this to delete anything after this point. (command "_copy" ss "" "_NONE" pt "_NONE" '(0.0 0.0 0.0)) ) ) ;(command "_.zoom" "_object" ss "") (if (and (sssetfirst nil (ssget "_P")) (setq text (if (setq text (car (nentsel "\nget text "))) (setq text (cdr (assoc 1 (entget text))))) Name (getfiled "Export save as: " (strcat (getvar "DWGPREFIX") (if text (strcat text ".dxf") "")) "dxf" 1) ) ) (command "dxfout" Name "V" "2007" "O" "_P" "" "") ) (if (setq en (entnext LastEnt)) (while en (entdel en) ;Deletes everything that was copied up to the bookmarked LastEnt (setq en (entnext en)) ) ) ;(command "._erase" ss "") ;dont need "_object" when using Selection Set ;(command "_.zoom" "v") (princ) )
    1 point
  5. First, we get the length of the list as a whole, i.e. the number of items in that list (stored in variable n). Then we remove every occurrence of that element from the list using vl-remove and take its length, which is (length (vl-remove (car a) l)). Subtracting the total length with the removed length gives you the number of occurrences of that item in the list, so if it's not equal to 1 (or greater than 1), remove that item from the list. So: l is stored as (1 1 2) and n as 3. Let's take the last item of the list, a=(2 (<Entity name: 8290ba00>)) (car a) = 2 (vl-remove 2 l) = (1 1) (length (1 1)) = 2 (- n 2) --> (- 3 2) = 1 (= 1 1) = T, therefore remove item from list. So if a=(1 (<Entity name: 8290b880>)): (car a) = 1 (vl-remove 1 l) = (2) (length (2)) = 1 (- n 1) --> (- 3 1) = 2 (= 2 1) = nil, therefore do not remove item from list. By the way, debugging is something that programmers must be able to perform. You can use it in this case too even thought it doesn't yield any errors. But I have to say, that it does yield an error when I first write it up and tested it. No matter how skilled anyone is at programming (myself, Lee, and all the best programmers out there), you're bound to make a mistake at some point, especially codes with thousands of lines, so it's good to know where they occur in order to be able to fix the error. To do that, we use the debugging feature of AutoLISP. These can include step-by-step execution and variable watching. Lee Mac has provided an excellent tutorial in this link and it is VERY important for programmers to be able to use this. You can also use it in this scenario to see how the code functions.
    1 point
  6. OSNAPOVERRIDE (System Variable) https://help.autodesk.com/view/ACD/2022/ENU/?guid=GUID-F3B84568-4B41-427C-8B9F-FE4C1E547D9D Prevents overrides to default object snap settings. With it set to 1 only the current running object snap settings can be used unless you select another osnap first, you cannot pick a point in blank space or use a different osnap otherwise. Teach that beginner when snapping to an endpoint in an area there's other points to snap to close by picking anywhere on that half of that line segment that's not near anything else will prevent them from snapping to the wrong point by accident.
    1 point
  7. You could make the Aperture box bigger.
    1 point
  8. Does the FIND command not work for you ?
    1 point
  9. You only need to look at how a text field is made for a Z value of existing text and overwrite string, using VL-put-textstring obj newstr. You can copy the manual field command line and edit it into a lisp. Use mtext as a test. (defun c:t2rl ( / ss obj str) (setq ss (ssget (list (cons 0 "TEXT")))) (repeat (setq x (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1))))) (setq str (strcat "%<\\AcObjProp Object(%<\\_ObjId " (itoa (vla-get-Objectid obj)) ">%).InsertionPoint \\f \"%lu6%pt4\">%")) (vla-put-textstring obj str) ) (command "regen") (princ) )
    1 point
×
×
  • Create New...