PDA

View Full Version : creating a macro/command button?



neil.hughes
2009-11-18, 11:38 AM
Hi, bigtime newcomer to this.
Summary: An Autolisp function or command button to select all, change colours and to move certain items so much in X & Y.

Description: I could do with making a macro of some description to basically select all on a drawing, change all the colour to white, then I need to select a certain area change to red (as it’s a security stamp and can only be in red) then I need to select another area on the drawing which is always going to be the same and to move what’s there 2mm to the left and 1mm upwards.

How Used: I’ve basically got loads of drawings I need to change everything to white so when I create a DWF file our client can read and the stamp will always be in red.

neil.hughes
2009-11-18, 12:12 PM
So far I have this working:
^C^C_ai_selall;'_color;

Basically selecting all in the drawing then the colour menu comes up, I click a colour, press OK, then it returns to the drawing, but the items dont change to the colour i chose.

Any idea's?

rkmcswain
2009-11-18, 05:22 PM
Basically selecting all in the drawing then the colour menu comes up, I click a colour, press OK, then it returns to the drawing, but the items dont change to the colour i chose.

Items in blocks will only change color if their assigned color in the block is BYBLOCK.
Are the items that are not changing blocks, or other entity types?

Ed Jobe
2009-11-19, 01:06 AM
So far I have this working:
^C^C_ai_selall;'_color;

Basically selecting all in the drawing then the colour menu comes up, I click a colour, press OK, then it returns to the drawing, but the items dont change to the colour i chose.

Any idea's?
I've moved this from the api wishlist to the lisp forum. The api wishlist is for modifying objects in the ActiveX api.

irneb
2009-11-19, 07:48 AM
So far I have this working:
^C^C_ai_selall;'_color;

Basically selecting all in the drawing then the colour menu comes up, I click a colour, press OK, then it returns to the drawing, but the items dont change to the colour i chose.

Any idea's?The Color command simply sets the current color, it doesn't edit existing entities. For modifications like that you could use the CHANGE command (or in Lisp entmod / vlax properties if you want to go that route)

You could try using PSelect to have the user select entities for the change to red & move commands. But I'd advise going the Lisp route for this as macros don't always work nicely when user input is required.

Regarding the stamp & moving area. Are these always on the same place in each drawing? If always the same the selection could also be automated in Lisp.

neil.hughes
2009-11-19, 10:20 AM
firstly thanks to all that replied.
also sorry for putting in wrong forum thread - i wasn't quite sure.
the red stamp actually is now moving around so - if poss, it would be better if i could actually put a box around it then pick the colour red?
i'll try and have a mess with the 'COMMAND' and entmod..... - as you can see i'm a complete noob at this.
don't suppose there's a link to a site with all the commands a small description of what they all do is there online anywhere???

thanks again for taking time out to reply peeps, much obliged !!!

neil.hughes
2009-11-19, 11:56 AM
I've got the following to work so far:
^C^C_purge;^C^C_purge;^C^C_Y;^C^C_ai_selall;/^C^C_setbylayer;'_zoom _w ;$M=$(if,$(getvar,cmdactive),,_select; )_w ;

1 - Load drawing
2 - Click Icon I created that runs macro above
3 - Purges twice, then it zooms in (even though zoom is at the end??)
4 - When its zoomed in it then asks about putting everything to bylayer.... so I say yes & everything turns white - which is all brill so far.

Then if at all possible -

1 - I'd like it to have a bit of wording at the bottom that when I press the Icon straight after I'd like it to say - "Press 'Y' to continue" or something like that.
2 - Also if poss (bit more technical) - is there a way of it remembering the points where i've clicked to zoom in then for it to use those same points to put a box around the stamp that I need to turn red.

Any idea's peeps - I'll be amazed if I can get this to work!!!

neil.hughes
2009-11-20, 12:15 PM
Binned this idea and started again, see below what i changed to make it work:

1 - I created a script called "test.scr" and placed in my C:\Plotfiles folder.
It consisted of:
;; CREATES A LAYER CALLED STAMP IN RED COLOUR
_LAYER N STAMP SET STAMP COLOR 1 STAMP
;; PUTS EVERYTHING ON DRAWING TO BE SET WITH BYLAYER
_SETBYLAYER ALL Y Y

2 - I edited the Macro I created with the following line:
^C^C_script
C:/Plotfiles/test.scr;_laycur;

So it now basically does what I want.
Would like a window to pop up to ask whether i'd want to run the macro after I press the button as I could click it on accident - so if anyone could help with that idea, i'd be really grateful.

Thanks again to those that helped, much appreciated. !!

irneb
2009-11-27, 02:46 PM
For that I think you need to go to Lisp. Create a DCL file to show the dialog and only run the script if the user clicked the Yes or OK button.

mvsawyer
2009-12-02, 07:17 PM
Why use a script file? Add the lines of code to the button on the toolbar.

^C^CLAYER N STAMP S STAMP C 1 STAMP ^C^CSETBYLAYER ALL Y Y

This way you could share the macro with others and also do not have to worry about external files. Also, if you're afraid you'd click it by accident add command undo begin and end so that if you accidentally click it, you can type U and it'll be like it all never happened.


^C^CUNDO;BE;LAYER;N;STAMP;S;STAMP;C;1;STAMP;;^C^CSETBYLAYER;ALL;;Y;Y;UNDO;E;