Jump to content

Recommended Posts

Posted

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!

  • Replies 41
  • Created
  • Last Reply

Top Posters In This Topic

  • alanjt

    17

  • The Buzzard

    7

  • MichaelJ07

    7

  • adamsnez

    5

Top Posters In This Topic

Posted
(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)
)

Posted

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)
)

Posted
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.

Posted

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...)

Posted
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 :)

Posted
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.

Posted

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)

)

Posted

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.

Posted

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 !

Posted

edit:

replied to someone who deleted their comment just now

Posted
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.

Posted

It was more or less the same post as yours, no need for redundancy. I guess I wasn't quick enough.

Posted
It was more or less the same post as yours, no need for redundancy.

Agreed.......

Posted
Agreed.......

 

You mean like this?:wink:

Posted

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....:D Sometimes, me thinks some of you been starring at a computer screen for too many years.

Posted
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....:D 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).

Posted
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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...