Macro using right mouseclick to exit - what am I doing wrong?
- August 1, 2012
- 1 reply
- 1812 views
We often do wiring diagrams.
We add cuttout loops where wires cross, so my macro places a pre-drawn cuttout loop at the point picked by left mouse click.
It then repeats until right mouse click, when it's supposed to exit.
The problem is that it doesn't seem to exit the while loop properly. If you left click on the drawing, it adds the cutout loop drawing OK, and repeats, but when you right click it still keeps repeating - unless you hold the right button for a second or more, but then it selects all the loops you've added to the drawing so far and changes the line type of one of them (as though you've double clicked on it).
A simplified version of the macro is below.
Strange thing is that if I uncomment the message lines below, the macro seems to work OK, (though with the annoying popup messages of course), except that the first one returns 0 (no mouse click) instead of the expected 1 (left mouse click).
I'm obviously doing something wrong but I can't figure it - any of you clever guys help?
I've attached the cutout loop file, you will just need to change the place line in the macro to where you put the file.
macro test-add-wiring-diagram-cutout-loop
define me as MouseEvent
define ppx1 as Point # x value of user selected point
define ppy1 as Point # y value of user selected point
While (me.Click <> 2)
me = Wait MouseClick
if(me.Click <> 2)
#message me.click
#NOTE THAT ABOVE RETURNS 0, NOT THE EXPECTED 1
ppx1 = me.ptMMGrid.x
ppy1 = me.ptMMGrid.y
place "X:\Illustrators Info\Macros\wiring-diagram-cutout-loop.iso" (ppx1-1) (ppy1-1)(ppx1+1) (ppy1+1)
Select if type is equal to 'Placed_file'
Import selection #BREAKS THE LINK WITH THE PLACED FILE
Select None
else
Select None
end if
End While
#message me.click
end macro

