Jump to content

All Activity

This stream auto-updates

  1. Today
  2. I assume you're referring to commands defined in Lisp code. One way to do this is to call ATOMS-FAMILY, save its contents in a variable, call ATOMS-FAMILY again when the drawing is about to be closed, compare the difference, and filter out symbols that don't begin with "c:" But why do you need to do this?
  3. Good day to everyone. Is it possible to display a list of AutoLISP commands before closing and saving the dwg file? For example, in notepad or text in dwg.
  4. GLAVCVS

    Selection set filter

    According to your original code, the dimension drawn when the command is executed isn't changed. Only the existing dimensions are. Therefore, the call to DIMORDINATE should be made at the end of the loop, like this: (defun C:or (/ dst w m x y cj e n) (prompt "\nSet UCS at 0,0") (while (setq w (getpoint "\nFirst point")) (setq m (getpoint w) x (car w) y (cadr w) n nil ) (setvar "osmode" 0) (if (> X 10) (if (setq cj (ssget "_F" (list w m) (list (cons 0 "DIMENSION")))) ;if (while (and cj (setq e (ssname cj (setq n (if n (1+ n) 0))))) (entmod (append (entget e) (list (cons 62 1)))) ) ) ) (command "_dimordinate" w M) ) ;while (setvar "osmode" 511) )
  5. Yesterday
  6. You are right about learning lisp the CAD suppliers give you example of how to use a lisp function but really no actual step by step tutorials. Look for Graden path tutorial if using Acad. A good tutorial. Ther are some good books out there I found some on kindle very cheap and can copy code from the electronic book. Also a good reference is 'The visual Lisp Developers Bible" Agree Afralisp has come good tutorials. A comment "6. Analyze the layers" we used to process output from other software brought into cad so had a text file with all the layer details, Oldname Newname etc. Eg for road surveys had a existing layer LIP it was renamed EX-LIP and color changed, when designing a layer called LIP was known then as a design layer.
  7. Tsuky

    switch to turn on or off a variable

    Or this, for toggle (defun c:SF ( / ) (if (zerop (boole 1 (getvar "UCSFOLLOW") 1)) (progn (setvar "UCSFOLLOW" (1+ (getvar "UCSFOLLOW"))) (princ "\nUCS Follow Activado") ) (progn (setvar "UCSFOLLOW" (1- (getvar "UCSFOLLOW"))) (princ "\nUCS Follow Desactivado") ) ) (prin1) )
  8. Haven't really looked at the rest of your code , simply changed the getfolder & split text part and pasted the rest. As far for learning , there are lots of posts here on this site asking the same thing so no use summing them up all again but Lee Mac's site and Afralisp are good places to start. Just kiss... (keep it simple stupid) , start easy and if you like it enough you'll find the motivation to take it next level. Lisp has some quirks & limitations but for many (repeating) tasks you can get great results with relatively little effort once you get the hang of it. But some lisp concepts will need a little time to sink in (if ever). 3d and matrixes for example are not really my thing but that's because I use them so little , when I need them I beg , steal , borrow , cut , copy & paste something together until it works and forget all about it until I need it again.
  9. GLAVCVS

    switch to turn on or off a variable

    'repeat 100...'? Changing the same variable 100 times...why? I guess that's a mistake. Something simple: every time the command sf is called, UCSFOLLOW changes state, without asking (defun c:sf (/ act) (setvar "UCSFOLLOW" (if (setq act (= (getvar "UCSFOLLOW") 0)) 1 0)) (princ (strcat "\n*** Variable UCSFOLLOW " (if act "activada" "desactivada"))) (princ) )
  10. hello : I use this code to quickly change a variable on or off. I would like to know if someone can improve it in appearance or functionality.
  11. Thanks for the reply, RLX! I would love to learn how to do this myself, but I've had a hard time finding any instructional resources. Seems you just have to work with somebody that knows and get taught. Autodesk has very little about writing LISP's. If you know of any resources, I'm all ears. I would rather be in charge of the coding than doing this iterative, dystopian machine-building-machine nonsense. But for now, CoPilot writes a code, I read the code and get a sense of what it does, then I change the code and read it again and I'm at least starting to lay the groundwork that way. As far as your code, it didn't throw any errors and it brought in all the xref's but it didn't change the layer colors. I do like the folder dialogue you used better though and not throwing errors is a huge step in the right direction. Thank you. I'll keep messing with it.
  12. Sorry. I'll do that next time.
  13. GLAVCVS

    Selection set filter

    Try (defun C:or (/ dst w m x y cj e n) (prompt "\nSet UCS at 0,0") (while (setq w (getpoint "\nFirst point")) (setq m (getpoint w) x (car w) y (cadr w) n nil ) (setvar "osmode" 0) (command "_dimordinate" w M) (if (> X 10) (if (setq cj (ssget "_F" (list w m) (list (cons 0 "DIMENSION")))) ;if (while (and cj (setq e (ssname cj (setq n (if n (1+ n) 0))))) (entmod (append (entget e) (list (cons 62 1)))) ) ) ) ) ;while (setvar "osmode" 511) )
  14. maahee

    Selection set filter

    I only want to select the dimension that goes through the specific x-axis point and y-axis is veriable. example point (13,17) (15, 18) co-ordinate greater than 10, select dimension which goes through co-ordinate 13, 15.
  15. GLAVCVS

    Selection set filter

    Your question seems a little confusing to me. What do you want to achieve?
  16. maahee

    Selection set filter

    (defun C:or (/ dst) (prompt "\set UCS at 0,0") (while (setq w (getpoint)) (setq m (getpoint)) (setq x (car w)) (setq y (cadr w)) (setvar "osmode" 0) (if (< X 10) (command "dimordinate" w M ) (progn (setq e (ssget "X" (list '(0 . "DIMENSION") (CONS 42 X)))) (command "dimordinate" w M ) (command "_.CHPROP" e "" "_color" 1 "") ;;;;code;;;; ) ;progn ) ;if ) ;while (setvar "osmode" 511) ) (setq e (ssget "X" (list '(0 . "DIMENSION") (CONS 42 X)))) It does not create any selection set, dimension passing through only x-cordinate
  17. CyberAngel

    .DXF files not showing up

    My guess is they mean they set their DWGUNITS variable to 3, which changes units to mm. But it doesn't sound like that's the real problem. They mentioned a new template, may be something there.
  18. Last week
  19. BIGAL

    .DXF files not showing up

    Does not sound right an inch is 25.4 mm. So need to scale accordingly using that factor. Zoom extents should find. Post a dwg as suggested.
  20. if you just want to go up and down use Ctrl+Pgdn, Ctrl+Pgup. This will let you jump to any layout. Goto-layout.lsp
  21. without the actual drawings unable to test this so this is untested : (defun c:BatchXref ( / skipList folder curPhase prevPhases phaseList ) (setq skipList '("X-TTLB.dwg" "X-DETL.dwg" "X-LGND.dwg")) (setq folder (GetShellFolder "Select target folder")) ;;; Prompt for current phase number (setq curPhase (getstring "\nEnter current phase number (e.g., 03): ")) ;;; Prompt for previous phase numbers (setq prevPhases (getstring "\nEnter previous phase numbers (comma-separated, e.g., 01,02): ")) ;;; split up previous phases (setq phaseList (SplitStr prevPhases ",")) ;; Display phase info (princ (strcat "\nCurrent Phase: X-BASE-UN" curPhase)) (princ (strcat "\nPrevious Phases: " (apply 'strcat (mapcar (function (lambda (p) (strcat " " p))) phaseList)))) ;;; Create X-REF layer if needed (if (not (tblsearch "LAYER" "X-REF")) (command "_.-LAYER" "_Make" "X-REF" "_Color" "7" "X-REF" "")) ;;; Get DWG files (if (vl-consp (setq files (vl-directory-files folder "*.dwg" 1))) (progn ;;; Insert XREFs (foreach file files (if (not (member (strcase file) (mapcar 'strcase skipList))) (progn (setq fullpath (strcat folder file)) (command "_.-XREF" "_Overlay" fullpath '(0 0 0) 1 1 0) (command "_.CHPROP" "L" "" "_LA" "X-REF" "") ) ) ) ;;; Lock the layer (command "_.-LAYER" "_Lock" "X-REF" "") ;;; Change color of layers with previous phase names in XREF or nested XREF (setq layerTable (tblnext "LAYER" T)) (while layerTable (setq layerName (cdr (assoc 2 layerTable))) (setq matched nil) ;;; *** vl-string-split *** made up by glorified paperclip ;;; Split layer name into parts (XREF nesting) (setq xrefParts (SplitStr layerName "|")) ;;; Check each part for a match with previous phase names (foreach part xrefParts (if (member (strcase part) phaseList) (setq matched T))) ;;; If matched, change layer color using entmod (if matched (progn (setq layerEnt (tblobjname "LAYER" layerName)) (if layerEnt (progn (setq layerData (entget layerEnt)) (if (assoc 62 layerData) (setq layerData (subst (cons 62 251) (assoc 62 layerData) layerData)) (setq layerData (append layerData (list (cons 62 251)))) ) (entmod layerData) (entupd layerEnt) ) ) ) ) (setq layerTable (tblnext "LAYER")) ) (princ "\nOverlay XREFs added. Layers in matching XREFs and nested XREFs set to color 251.") ) (princ "\nNo folder selected / files to proces") ) (princ) ) ;;; s = string d = delimiter p = position delimiter (setq r (SplitStr "01,02" ",")) -> '("01" "02") (defun SplitStr ( s d / p ) (if (setq p (vl-string-search d s))(cons (substr s 1 p) (SplitStr (substr s (+ p 1 (strlen d))) d)) (list s))) ;;; (setq f (GetShellFolder "Select a folder")) -> "C:\\Temp\\Lisp\\" (defun GetShellFolder ( m / f s) (if (and (setq s (vlax-create-object "Shell.Application")) (setq f (vlax-invoke s 'browseforfolder 0 m 65536 "")))(setq f (vlax-get-property (vlax-get-property f 'self) 'path)) (setq f nil))(vl-catch-all-apply 'vlax-release-object (list s)) (if f (strcat (vl-string-right-trim "\\" (vl-string-translate "/" "\\" f)) "\\"))) Just a couple remarks : getfolder (or GetShellFolder) is more generic than selecting a drawing and stripping out path. It's not wrong but soooo last century. ChatGPT or Copilot : stop using them and learn to do it yourself. As long as those glorified paperclips are not star-trek level you can't trust them. They make up commands like in your code : (setq xrefParts (vl-string-split layerName "|")) , maybe somebody at one time created this (vl-string-split) as a custom defun but in my visual lisp editor it didn't turn blue so its not a core command. I replaced it with SplitStr. Oh I also don't see a save command anywhere so I assume that's handled by you or Copilot? I hope code above works , if not... bite me
  22. In the future, please use Code Tags for your code. (<> in the editor toolbar)
  23. Hello all! I work in the land development field and I'm trying to use Microsoft Copilot to write some LISP routines to make our sheet production easier on multi-phase subdivision projects. Each phase will have a separate job folder with separate xref's, C3D data files and a sheetset. Our base files will follow a naming convention that includes the unit number. So for unit 1 the base file would be X-BASE-UN01 and so on. In our base files for a given unit, we'll have a file called X-BASE-PREV-UNXX. This will have no data in and of itself, but will contain attached xref's of previous unit base files that need to be shown as existing on the current unit plans. It's essentially a one stop shop so I don't have to go hunting through 4 different job folders to find the previous unit base files every time I set up a new sheet. I'm wanting this LISP routine to do the following: 1. Prompt the user for a path to look for xref's. 2. Prompt the user for the current phase number 3. Prompt the user for previous phase numbers 4. Bring in all dwg files in the supplied location, with the exception of the titleblock, legend base and detail base. 5. Place the xref's on the X-REF layer (and make one if it doesn't exist) and lock it. 6. Analyze the layers in the drawing and change the colors of any layer in an xref that matches the user input for previous phases to 251. Eventually, I'll expand this into several LISP routines and have them do specific layer control for the sheet depending on the discipline (i.e. one for street sheets, one for sewer, one for water one for drainage). That's why I have it asking for the current unit number. But I need to get this basic framework in place first. The code that Copilot is giving me will go through the first three steps just fine but then returns an ;error too few arguments when it comes time to bring in the references. I've pasted the code below. I appreciate any light y'all can shed on this since I know very little about LISP coding or how it works (why I'm trying to use CoPilot to do this). (defun c:BatchXref ( / folder files file skipList fullpath curPhase prevPhases phaseList layerTable layerName xrefParts matched layerEnt layerData) (setq skipList '("X-TTLB.dwg" "X-DETL.dwg" "X-LGND.dwg")) ;; Prompt for folder path using file dialog (setq folder (getfiled "Select any DWG file in target folder" "" "dwg" 8)) (if folder (progn ;; Ensure folder ends with a backslash (setq folder (vl-filename-directory folder)) (if (/= (substr folder (strlen folder)) "\\") (setq folder (strcat folder "\\"))) ;; Prompt for current phase number (setq curPhase (getstring "\nEnter current phase number (e.g., 03): ")) ;; Prompt for previous phase numbers (setq prevPhases (getstring "\nEnter previous phase numbers (comma-separated, e.g., 01,02): ")) (setq phaseList (mapcar (function (lambda (x) (strcase (strcat "X-BASE-UN" x)))) (vl-remove "" (mapcar 'vl-string-trim (vl-string->list (vl-string-translate "," " " prevPhases)))) ) ) ;; Display phase info (princ (strcat "\nCurrent Phase: X-BASE-UN" curPhase)) (princ (strcat "\nPrevious Phases: " (apply 'strcat (mapcar (function (lambda (p) (strcat " " p))) phaseList)))) ;; Create X-REF layer if needed (if (not (tblsearch "LAYER" "X-REF")) (command "_.-LAYER" "_Make" "X-REF" "_Color" "7" "X-REF" "") ) ;; Get DWG files (setq files (vl-directory-files folder "*.dwg" 1)) ;; Insert XREFs (foreach file files (if (not (member (strcase file) (mapcar 'strcase skipList))) (progn (setq fullpath (strcat folder file)) (command "_.-XREF" "_Overlay" fullpath '(0 0 0) 1 1 0) (command "_.CHPROP" "L" "" "_LA" "X-REF" "") ) ) ) ;; Lock the layer (command "_.-LAYER" "_Lock" "X-REF" "") ;; Change color of layers with previous phase names in XREF or nested XREF (setq layerTable (tblnext "LAYER" T)) (while layerTable (setq layerName (cdr (assoc 2 layerTable))) (setq matched nil) ;; Split layer name into parts (XREF nesting) (setq xrefParts (vl-string-split layerName "|")) ;; Check each part for a match with previous phase names (foreach part xrefParts (if (member (strcase part) phaseList) (setq matched T) ) ) ;; If matched, change layer color using entmod (if matched (progn (setq layerEnt (tblobjname "LAYER" layerName)) (if layerEnt (progn (setq layerData (entget layerEnt)) (if (assoc 62 layerData) (setq layerData (subst (cons 62 251) (assoc 62 layerData) layerData)) (setq layerData (append layerData (list (cons 62 251)))) ) (entmod layerData) (entupd layerEnt) ) ) ) ) (setq layerTable (tblnext "LAYER")) ) (princ "\nOverlay XREFs added. Layers in matching XREFs and nested XREFs set to color 251.") ) (princ "\nNo folder selected.") ) (princ) )
  24. BCDJOHN123

    .DXF files not showing up

    On the drawing, I do the DWGUNITS command and change units to (3) millimeters and press enter for all the other settings. When it converts, it will disappear from view, and I'll usually double-click the mouse scroller to find it.
  25. SLW210

    .DXF files not showing up

    Hard to say without a drawing to look at. Most likely something to do with going from inches to mm, what is the process for doing the conversion?
  26. In the future please use Code Tags for your code. (<> in the editor toolbar)
  27. Hello. I have a multileader entity. I want to add additional leaders to my multileader. acadObj is the ActiveX object of my multileader. This is how I made it work for me: (setq muu_lead_vert_new_indx (vla-AddLeader acadObj)) (setq muu_lead_vertices_new (vlax-make-safearray vlax-vbdouble '(0 . 8))) (vlax-safearray-fill muu_lead_vertices_new (list pt1 pt2 pt3)) (vla-AddLeaderLine acadObj muu_lead_vert_new_indx muu_lead_vertices_new) It pretty much does the trick, but not as neat as I want it. If I add multiple leaders, and then I want to work with the new leaders... I search for new leaders via: (vlax-invoke acadObj 'getleaderlineindexes 0) (vlax-invoke acadObj 'getleaderlineindexes 1) but 1st command returns '(0), and the second one returns '(1), even if I already have 5 or 8 or 10 leaders on my multileader. An ugly way around that I found, is the following: (setq sbe_ml_indxlist (vl-sort (append (vlax-invoke acadObj 'getleaderlineindexes 0) (vlax-invoke acadObj 'getleaderlineindexes 1)) '<)) (and (/= (length sbe_ml_indxlist) (vla-get-LeaderCount acadObj)) (foreach memb '(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20) (and (not (vl-catch-all-error-p (vl-catch-all-apply '(lambda (x) (vla-GetLeaderIndex acadObj x)) (list memb)))) (setq sbe_ml_indxlist (append sbe_ml_indxlist (list memb)))))) The idea is: I make a list of leader indexes (first 2 lines). In my code I have more lines prior to it... with some verifications... but the idea is that sbe_ml_indxlist in first 2 lines should get all existing leader line indexes. Next 4 lines, check: If leader indexes added via vla-AddLeaderLine do not end in the list composed by getleaderlineindexes, I check 1 by 1, if a leader with index X exists, it adds that index to the list of existing indexes. There are still many problems... I don't want to get into too much detail... because my post is not about "solving 20 problems"... which result from damaging the multileader entity... My post is about: "please tell me the right way to add leaders to existing multileader" Some of extra-problems with multileader on which I did run vla-AddLeader, just fyi: 1. One time I had a multileader with 10+ leaders, but vla-get-leadercount showed 8 leaders. After I copied the multileader, the new one was returning 7 from vla-get-leadercount. 2. If I add leaders via (command "_.mleaderedit" entname "A" $ pause), than the ones added to the left of multileader are seen via getLeaderLineIndexes but the ones added to the right are not seen. 3. Once I had a case that getLeaderLineIndexes did not return 0-index leader... but (getLeaderIndex acadObj 0) showed that such a leader exists, but I can't recreate it.
  1. Load more activity
×
×
  • Create New...