adamsnez Posted April 28, 2010 Posted April 28, 2010 I have a button called "match". Currently when you hit it, you select any dimstyle in drawing and it makes it the current dimstyle. Macro code is "^C^C-dimstyle;;;" i want to incorporate layer into this as well, example My current dimstyle is Metric5_arrows, layer "wall". I want click on a text where dimstyle is Metric25_dots, layer "text". Now when i click that text, the current dimstyle changes to Metric25_dots, and the current layer switches to txt, from previous "wall". How do i code this into my Match button? I got that "^C^C-dimstyle;;;" from someone in the office, just not efficient enough for me. THANKS! Quote
alanjt Posted April 28, 2010 Posted April 28, 2010 (defun c:test (/ e) (and (setq e (car (entsel "\nSelect Dimension: "))) (or (eq "DIMENSION" (cdr (assoc 0 (setq e (entget e))))) (alert "Invalid object!") ) (setvar 'clayer (cdr (assoc 8 e))) (command "_.-dimstyle" "_restore" (cdr (assoc 3 e))) ) (princ) ) Quote
Lee Mac Posted April 28, 2010 Posted April 28, 2010 Things look very different in VL (defun c:DimMatch ( / doc obj ) (vl-load-com) (defun Itemp ( coll item ) (if (not (vl-catch-all-error-p (setq item (vl-catch-all-apply (function vla-item) (list coll item) ) ) ) ) item ) ) (if (progn (vla-GetEntity (vla-get-Utility (setq doc (vla-get-ActiveDocument (vlax-get-Acad-Object) ) ) ) 'obj "\nSelect Dimension: " ) (and obj (wcmatch (strcase (vla-get-ObjectName obj) ) "*DIMENSION*,*LEADER" ) ) ) (mapcar (function (lambda ( Information ) (apply (function (lambda ( Dest Collection Source ) (vlax-put-property doc Dest (itemp Collection (vlax-get-property obj Source) ) ) ) ) Information ) ) ) (list (list (quote ActiveLayer) (vla-get-layers doc) (quote Layer)) (list (quote ActiveDimstyle)(vla-get-Dimstyles doc) (quote StyleName)) ) ) ) (princ) ) Quote
alanjt Posted April 28, 2010 Posted April 28, 2010 Things look very different in VL I thought about using VL, but he's making button macros. Seemed logical to keep it as simple as possible. Quote
adamsnez Posted April 28, 2010 Author Posted April 28, 2010 thanks guys, i TOTALLY don't know how to implement this though.... I'm not a coding guy at all. i was trying to paste this code into the CUI-->find my Match tool--> then under the "macro" there i pasted into the 'long string editor'.... Didn't work. How do I get this running?! I've never even seen the types of code before you guys posted up. Is it some VB thing? Do i need VBEditor installed? (installing that now btw, it wasn't before...) Quote
Lee Mac Posted April 28, 2010 Posted April 28, 2010 Perhaps take a look here: http://www.cadtutor.net/forum/showthread.php?t=1390 My code in VL was more for academia than anything else. Quote
Lee Mac Posted April 28, 2010 Posted April 28, 2010 Is it some VB thing? Do i need VBEditor installed? (installing that now btw, it wasn't before...) This is LISP code, not Visual Basic, you don't need the VBEditor - AutoCAD has everything you need already installed Quote
alanjt Posted April 28, 2010 Posted April 28, 2010 thanks guys, i TOTALLY don't know how to implement this though....I'm not a coding guy at all. i was trying to paste this code into the CUI-->find my Match tool--> then under the "macro" there i pasted into the 'long string editor'.... Didn't work. How do I get this running?! I've never even seen the types of code before you guys posted up. Is it some VB thing? Do i need VBEditor installed? (installing that now btw, it wasn't before...) You're very welcome. My code in VL was more for academia than anything else. I know. Quote
adamsnez Posted April 29, 2010 Author Posted April 29, 2010 Ya, not sure why this still isn't working, but my button link isn't finding!!! lisp located @ let's say "C:/acad/match.lsp" i found on another site to put this in my button macro field ^C^C^C(load C:/acad/match.lsp"); but that doesn't load it when i hit the button i've added to my toolbar! it says in the command line "Command: (load C:/acad/match.lsp") then beneath it says ("_> where you would normally type in a command the only thing i modded from the lisp you guys gave me was changed the notes and "test" to "match" when i realized i had to TYPE it in to load it, but i want it on a button instead of typing "match" always. ;;MATCH.LSP SELECT A DIMSTYLE TEXT, AND THAT DIMSTYLE AND LAYER BECOME CURRENT ;; VERY USEFUL FOR TICKETS ;;=========================================================================== ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MAIN PROGRAM ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun c:Match (/ e) (and (setq e (car (entsel "\nSelect Dimension: "))) (or (eq "DIMENSION" (cdr (assoc 0 (setq e (entget e))))) (alert "Invalid object!") ) (setvar 'clayer (cdr (assoc 8 e))) (command "_.-dimstyle" "_restore" (cdr (assoc 3 e))) ) (princ) ) Quote
alanjt Posted April 29, 2010 Posted April 29, 2010 You forgot a "" ^C^C(or c:Match (load "C:/acad/match.lsp" nil));MATCH; I'm not the best at buttons, but this should load (if not already) and execute the command. Quote
adamsnez Posted April 29, 2010 Author Posted April 29, 2010 sorry it was in there, just deleted it by accident in my reply (it still wasnt loading) BUT IT WORKS NOW THANK YOU SO MUCH THIS WILL save me a million amounts of seconds :0 ! Quote
adamsnez Posted April 29, 2010 Author Posted April 29, 2010 edit: replied to someone who deleted their comment just now Quote
alanjt Posted April 29, 2010 Posted April 29, 2010 sorry it was in there, just deleted it by accident in my reply (it still wasnt loading) BUT IT WORKS NOW THANK YOU SO MUCH THIS WILL save me a million amounts of seconds :0 ! You're welcome. edit:replied to someone who deleted their comment just now Larry had a good point through. I would replace the nil with "File not found" so you are prompted that it did not load. The use of nil is fine (it's just what I use by default), but for button loading, I would think you would want to be informed of the routine not loading, instead of nothing happening. Thanks for that Larry, no reason to have removed your post. Quote
lpseifert Posted April 29, 2010 Posted April 29, 2010 It was more or less the same post as yours, no need for redundancy. I guess I wasn't quick enough. Quote
alanjt Posted April 29, 2010 Posted April 29, 2010 It was more or less the same post as yours, no need for redundancy. Agreed....... Quote
MichaelJ07 Posted April 30, 2010 Posted April 30, 2010 Ok, first, great little button routine. Thanks for getting it going, adamsnez. I love button routines. However, when I run this lisp, the text window pops up and I have to X it closed. Any way to halt this from happening? Second, had a pretty crappy day until I opened this thread.... Sometimes, me thinks some of you been starring at a computer screen for too many years. Quote
alanjt Posted April 30, 2010 Posted April 30, 2010 Ok, first, great little button routine. Thanks for getting it going, adamsnez. I love button routines. However, when I run this lisp, the text window pops up and I have to X it closed. Any way to halt this from happening? Text screen? Are you talking about about (textscr) or the equivalent to hitting F2? There's nothing in the code that would open it. Very strange. Second, had a pretty crappy day until I opened this thread.... Sometimes, me thinks some of you been starring at a computer screen for too many years. I know I've spent too long behind a computer. I've been glued to one since I was 6 years old (286). Quote
MichaelJ07 Posted April 30, 2010 Posted April 30, 2010 Text screen? Are you talking about about (textscr) or the equivalent to hitting F2? There's nothing in the code that would open it. Very strange.It brings up the F2 box and I can't figure out why. I probably missed something in the code. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.