Macro keeps repeating the last command

Macro keeps repeating the last command

p.lepair
Explorer Explorer
192 Views
2 Replies
Message 1 of 3

Macro keeps repeating the last command

p.lepair
Explorer
Explorer

I have started this week with learning macro's and implementing them in a CUI Toolbar.

 

I made a macro, but it keeps repeating the last command. In this case, SETBYLAYER. I don't understand why. I have tried more or less ^C at the end or enters (;).

 

 

^C^CSSX;;C;;C;5;;^C^CCHPROP;p;;LA;_LS_BLUE-G;;^C^CSETBYLAYER;p;;Y;N;^C^C

 

 

What I want to do is select all the lines, polylines, circles, etc. in my drawing that have a color overwrite to blue (5) and place them on a layer I made. I have to do this for 22 colors, so I wanted to automate the process.

 

Any Tips?

 

Thank you in advance!

0 Likes
193 Views
2 Replies
Replies (2)
Message 2 of 3

ch9394
Contributor
Contributor

Hi, I've actually never built a macro before, but I was curious about this and noticed that no one has replied yet. "Enter" typically repeats a command in C3d. Knowing that, I used this article (here) and tried my hand at the formula, following each command step-by-step. This macro seemed to achieve the results you described without repeating the command : 

^C^CSSX;\;C;5;^C^CCHPROP;p;;LA;_LS_BLUE-G;;^C^CSETBYLAYER;P;;Y;N;^C^C

 

> The \ allows for user to select Circle, or whatever other object. There may be a way to select all items of color 5 with that command, but unfortunately I'm not sure how.

 

The only differences I'm seeing are: 

^C^CSSX;;C;;C;5;;^C^CCHPROP;p;;LA;_LS_BLUE-G;;^C^CSETBYLAYER;p;;Y;N;^C^C

 

What I'm reading with this Macro is: Command -> SSX --> Enter --> Prompt for Object Selection --> Nothing is selected with your macro --> Enter (Resulting in No Selection) --> SelectBy "C" (Color) -->[then a duplicated SelectBy "C" ] --> Color ="5" --> Enter --> [Duplicated Enter]

 

Again, this is the first time I've tried a macro out, so I don't have much info for you on why the one I provided seems to be working for me, but I would guess it has something to do with the extra enters and extra C?

 

I hope this helps!

0 Likes
Message 3 of 3

ch9394
Contributor
Contributor

Also, to validate your experience, when I tried different versions of that macro, they would also seem to "repeat" the last command, too. However, in my case, I found that it was simply dragging on the last command due to an error earlier in the function, essentially causing the entire function to stop prior to the submittal of the last command "SETBYLAYER". This looked like the command was repeating itself, when actually it was never performed in the first place. Maybe that was your original experience.

Anyway, good luck!

0 Likes