Macro for circle with a fixed diameter

I think we may have had this discussion before, but a long time ago…

I was doing a demo and I wanted to automate the repeated placement of circles of the same diameter. Certainly one can set the options, place the first, then right click to repeat the command, the diameter/radius option along with the value is saved and one can just click a new point to set it. However this requires right-clicking every time to recall the command. So I thought a macro using *_Circle should be possible… However, it seems difficult if not impossible.

The main problem is making sure that the command setting starts off on Diameter (or Radius) as one wants. If that is not done in the macro, then it will take the last used setting - which one does not know.

Let’s even forget about *repeat for now - as it’s not really related to the problem - and just try a macro that ensures Radius or Diameter will be used for the numerical value. Assuming that the current setting is Radius, then the following macro works - once:

! _Circle _Pause _Diameter 10.0

Here is the command line feedback, you can see the Diameter entry in the macro is setting the Circle command from Radius to Diameter.

Command: _Circle
Center of circle ( Deformable  Vertical  2Point  3Point  Tangent  AroundCurve  FitPoints ): _Pause
Center of circle ( Deformable  Vertical  2Point  3Point  Tangent  AroundCurve  FitPoints )
Radius <8.839> ( Diameter  Orientation  Circumference  Area  ProjectOsnap=Yes ): _Diameter
Diameter <17.679> ( Radius  Orientation  Circumference  Area  ProjectOsnap=Yes ): 10.0

The correct 10 diameter circle is placed at the pick point.

After the first time, if you run the macro again, since the command is already set to Diameter by the previous run, you get this instead:

Command: _Circle
Center of circle ( Deformable  Vertical  2Point  3Point  Tangent  AroundCurve  FitPoints ): _Pause
Center of circle ( Deformable  Vertical  2Point  3Point  Tangent  AroundCurve  FitPoints )
Diameter <10.000> ( Radius  Orientation  Circumference  Area  ProjectOsnap=Yes ): _Diameter
Select point on curve for diameter measurement. Press Enter when done ( Units=Model_Units  SelectCurve  MarkDiameter=No ): 10.0
Unknown command: 10.0
Select point on curve for diameter measurement. Press Enter when done ( Units=Model_Units  SelectCurve  MarkDiameter=No )

The Diameter *option* actually calls the Diameter *command* and everything goes south...

I tested in the WIP and this is still a problem. So, is this going to be adressed?

Note, I am not looking for scripted solutions, those are three liners I can easily create myself. This is just a comment on a ‘shortcoming’ of the way Circle has been programmed.

2 Likes

Hi mitch, if you use the “D” instead setting _Diameter the Macro work.
The only thing is that Rhino say “Unknown command: D” but at least doesn’t run the _Diameter command…
I agree that in this case the command’s options should have a fail safe setting to avoid the situation you described.
Funny thing: if you put an alias to “D” then that command would be processed… :grimacing:

Interesting - however this will maybe work in certain languages (latin-based ones I guess) but not all…

1 Like

Agree, the only way to fix the problem would be that Rhino has a special character to specify that you are passing a command option instead of a new command.
This would give the choice to run a command into another (i.e. osnap option) avoiding confusion between option’s names.

Hi Mitch - - it is a collision, I guess, between Circle (old stuff) and the more recent nestability of Diameter and other measurement commands. Thinking…
I suppose a way out is to change that option to Mode=Diameter/Radius. That could break a lot of existing macros but would get around the problem ‘moving forward’.

-Pascal

Putting a special character (like the underscore we use to pass a native command or the ! to kill an existing command) wouldn’t be more “stable”?
Let’s say that you use the “-” character: if the command is running and you specify a text with the minus, Rhino knows that you want to pass a command option…
Also, all the existing macros wouldn’t be affected because, without the minus character, Rhino would act normally: “option” if available or new command if no options selectable with that name.

EDIT obviously “-” wouldn’t be a choice because in use to run a command from command bar… :wink:

Yep, true, I tried in V5 and the macro

! _Circle _Pause _Diameter 10.0

works fine. In V6 it fails already. However, this doesn’t even work in V5:

! *_Circle _Pause _Diameter 10.0

That is because the *repeat will only repeat the circle command and not the whole macro.

Well, OK, I was just wanting to see if this simple task could be accomplished with a macro, clear that it can’t right now.

Yep, that’s one way I guess. I was also thinking if Diameter=10.0 or Radius=5.0 could be made to be interpreted correctly (not as running the nested Diameter command) this might also be a solution.

Mitch, try the repeater macro without the ! in front, that should not be there, I think.

-Pascal

OK, that does work in V5, but of course that will no longer cancel any already running command. If you run Line for example but don’t complete the command, then run the macro, it doesn’t work. And of course it doesn’t work in V6+…

Hello. You can do this with grasshopper player if the macro isn’t working. make the h file then save a macro of grasshopper player and its location ithink/ or just the name if it is in the default folder

Again, the post was not about looking for a script or a GH solution, I can do that myself.

import rhinoscriptsyntax as rs
while True:
    pt=rs.GetPoint()
    if not pt: break
    rs.AddCircle(pt,5.0)
1 Like

OK. My mistake.

No problem, that info was at the bottom of the first post, easy to miss…


If I write the macro in this way the Repeat works well.
A special character like @Diameter or #Diameter would be a way to force Rhino to recognize the parameter as an option instead of a new command.
The “!” at the beginning, instead won’t work as needed (Tried " *!_Circle _Pause _D 20 " but it needs a click to kill previous command and after first circle stops to repeat)

If ‘D’ is an alias for some other command, this will also fail I believe.

-Pascal

Yes, that’s what I told in previous message

This is why I suggested a new special character to avoid this problem (changing the command’s options is only a workaround until next exception… probably a never ending story… better if the user specify what he want to do in the macro).