Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/19/2021 in all areas

  1. Why not just load it with acad.lsp? As long as ACADLSPASDOC (System Variable) is set to it's initial value of 0 acad.lsp only loads when the first drawing is opened in a session. Don't use acaddoc.lsp to load it as it would load every time a drawing is opened which works well for most lisp routines.
    2 points
  2. (defun C:CHEENT (/ gruent grublockstocke gruotherentity index ename height point ok pointtocke) (setq gruent (ssget) grublockstocke (ssadd) gruotherentity (ssadd) ) (repeat (setq index (sslength gruent)) (setq ename (ssname gruent (setq index (1- index)))) (cond ((and (= (cdr (assoc 0 (entget ename))) "INSERT")(= (strcase (cdr (assoc 2 (entget ename)))) "TOCKE")) (ssadd ename grublockstocke) ) (T (ssadd ename gruotherentity) ) ) ) (setq grublockstocke (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex grublockstocke))))) (setq gruotherentity (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex gruotherentity))))) (foreach elem grublockstocke (setq height (cadr (assoc "HEIGHT" (mapcar '(lambda (elem1) (list (vla-get-tagstring elem1) (distof (vla-get-textstring elem1)))) (vlax-invoke elem 'Getattributes) ) ) ) ) (setq point (safearray-value (variant-value (vla-get-InsertionPoint elem)))) (vla-put-InsertionPoint elem (vlax-3d-point (list (car point) (cadr point) height))) ) (foreach elem gruotherentity (cond ((or (= (vla-get-ObjectName elem) "AcDbBlockReference") (= (vla-get-ObjectName elem) "AcDbText")) (setq index 0) (setq ok "OK") (while (and ok (< index (length grublockstocke)) (> (length grublockstocke) 0)) (setq point (safearray-value (variant-value (vla-get-InsertionPoint elem)))) (setq pointtocke (safearray-value (variant-value (vla-get-InsertionPoint (nth index grublockstocke))))) (if (equal (list (car point) (cadr point)) (list (car pointtocke) (cadr pointtocke)) 0.001) (progn (vla-put-InsertionPoint elem (vlax-3d-point (list (car point) (cadr point) (caddr pointtocke)))) (setq grublockstocke (vl-remove (nth index grublockstocke) grublockstocke)) (setq index 0) (setq ok nil) ) (setq index (1+ index)) ) ) ) ((= (vla-get-ObjectName elem) "AcDbLine") (setq index 0) (setq ok "OK") (while (and ok (< index (length grublockstocke)) (> (length grublockstocke) 0)) (setq point (safearray-value (variant-value (vla-get-StartPoint elem)))) (setq pointtocke (safearray-value (variant-value (vla-get-InsertionPoint (nth index grublockstocke))))) (if (equal (list (car point) (cadr point)) (list (car pointtocke) (cadr pointtocke)) 0.001) (progn (vla-put-Startpoint elem (vlax-3d-point (list (car point) (cadr point) (caddr pointtocke)))) (setq grublockstocke (vl-remove (nth index grublockstocke) grublockstocke)) (setq index 0) (setq ok nil) ) (setq index (1+ index)) ) ) (setq index 0) (setq ok "OK") (while (and ok (< index (length grublockstocke)) (> (length grublockstocke) 0)) (setq point (safearray-value (variant-value (vla-get-EndPoint elem)))) (setq pointtocke (safearray-value (variant-value (vla-get-InsertionPoint (nth index grublockstocke))))) (if (equal (list (car point) (cadr point)) (list (car pointtocke) (cadr pointtocke)) 0.001) (progn (vla-put-Endpoint elem (vlax-3d-point (list (car point) (cadr point) (caddr pointtocke)))) (setq grublockstocke (vl-remove (nth index grublockstocke) grublockstocke)) (setq index 0) (setq ok nil) ) (setq index (1+ index)) ) ) ) ) ) (princ) ) ;;;This list cancels and replaces the previous ones!! It should be OK, the CHEENT command puts the TOCKE blocks at the right height and with this reference fixes all the selected entities. For now, blocks, text and lines are included, but the selection can be extended later.
    1 point
  3. Many elite coders avoid Express Tools because some still have bugs (most easily fixed by replacing "command" calls with "command-s") in them but Help for them has been included in AutoCAD help in recent versions and I've used them since they started out as Bonus Tools. Many of them have been added as regular AutoCAD commands (most of the Layer commands for example), others have been dropped, while others around longer than Bonus Tools like Getsel.lsp and SSX.lsp are still considered Express Tools. Like Dadgad I use SYSVDLG (System Variable Editor…) and ALIASEDIT (Command Alias Editor…) on a regular basis as they provide a quick, simple, and helpful interface that eliminates simple mistakes. While some system variables are persistent, some are saved in the drawing, and some aren't saved at all when a drawing is closed environmental variables are saved in the Windows Registry where they remain unchanged. Keep in mind environmental variables saved in profiles may be different after switching profiles.
    1 point
  4. Thanks for the replies guys. @Dadgad I'll do some reading about that sysvar... not sure if that will effect my LISP loading - I'll check it out. Definately ACADLSPASDOC could be the go! @Steven P Good suggestion for a quick work-around. I've gone with this solution for now, though I used : (setenv "aeccoreloaded" "Loaded") @tombu I think this is exactly what I was looking for, thank you! Thanks guys
    1 point
  5. @tombu nailed it, there is much to be said for consistency. I just stumbled across this in the SYSVDLG, and was about to ammend my earlier suggestion. Here is the screenshot.
    1 point
  6. I'd make this into a LISP with a global string, if string is nil then do what you want at first opening CAD. After that is defined run the command in the LISP and set the file to load at startup LISP might be (untested): (defun c:loadaeccore ( / ) (if (= aeccoreloaded nil) (progn --DO WHATEVER YOU WANT AT INITIAL STATUP HERE-- (setq aeccoreloaded "Loaded") ) ;;end progn } ;;end if (princ aeccoreloaded) (princ) ) (c:loadaeccore)
    1 point
  7. (defun C:CHLINE (/ grublocks index ename height entgetename) (setq grulineblocks (ssget (list (cons -4 "<OR") (cons 0 "LINE") (cons -4 "<AND") (cons 0 "INSERT") (cons 2 (strcase "TOCKE")) (cons -4 "AND>") (cons -4 "OR>") ) ) gruline (ssadd) grublocks (ssadd) ) (repeat (setq index (sslength grulineblocks)) (setq ename (ssname grulineblocks (setq index (1- index)))) (cond ((= (cdr (assoc 0 (entget ename))) "LINE") (ssadd ename gruline) ) ((= (cdr (assoc 0 (entget ename))) "INSERT") (ssadd ename grublocks) ) ) ) (setq gruline (mapcar 'cadr (ssnamex gruline))) (setq grublocks (mapcar 'cadr (ssnamex grublocks))) (foreach elem gruline (foreach elem1 grublocks (if (equal (list (car (cdr (assoc 10 (entget elem)))) (cadr (cdr (assoc 10 (entget elem)))) ) (list (car (cdr (assoc 10 (entget elem1)))) (cadr (cdr (assoc 10 (entget elem1)))) ) 0.001 ) (progn (setq b1 (subst (list 10 (car (cdr (assoc 10 (entget elem)))) (cadr (cdr (assoc 10 (entget elem)))) (caddr (cdr (assoc 10 (entget elem1)))) ) (assoc 10 (entget elem)) (entget elem) ) ) (entmod b1) ) ) ) (foreach elem1 grublocks (if (equal (list (car (cdr (assoc 11 (entget elem)))) (cadr (cdr (assoc 11 (entget elem)))) ) (list (car (cdr (assoc 10 (entget elem1)))) (cadr (cdr (assoc 10 (entget elem1)))) ) 0.001 ) (progn (setq b1 (subst (list 11 (car (cdr (assoc 11 (entget elem)))) (cadr (cdr (assoc 11 (entget elem)))) (caddr (cdr (assoc 10 (entget elem1)))) ) (assoc 11 (entget elem)) (entget elem) ) ) (entmod b1) ) ) ) ) (princ) ) I threw this down in a pretty rough way, first you have to run the CHBLOCK command, then CHLINE. Basically the program searches line by line, which block corresponds to which x and y coordinates. When it has found it, it replaces the z-coordinate with that of the block, which has already been elevated. Give it a try and see if it works. For brevity's sake I didn't use the usual vla-vlax functions, I'll review it when I have a bit more time. For example, I mistakenly used the foreach function also for blocks, so once found the right block the program should stop searching and go to the next block, instead, of course, it continues. If there are few entities it can be fine, but if you start to have mega upon mega of drawing then it slows down noticeably.
    1 point
  8. I just reread your initial post, sounds like you want to set it to 2, like I do.
    1 point
  9. Post your changes then. Let's see what we can do differently to overcome your issue with the name. I would suggest using publish if you want multiple page pdfs
    1 point
  10. For 1 (vlax-for block (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) maybe do wcmatch i ie blk1002 ie found a block with 1002 in name ) for 2 I had a go using Multi radio buttons there is a option for A-Z its in the code examples at start of code, uses a defun to make the A-Z list its pushing the limits, use "H" horizontal option, when ran a variable BUT is set this is last item picked so default button will change to match last picked. (if (not AH:Butts)(load "Multi Radio buttons.lsp")) (if (not but)(setq but 16)) (setq ans2 (ah:butts but "h" (make_letters "Please choose" 65 26))) Multi radio buttons.lsp
    1 point
×
×
  • Create New...