Plug-in command assigned as an alias fails on first execution every Rhino session.
Steps to repeat:
Build a plug-in with the following test command RHTest in Rhinos ScriptEditor:
#! python3
import rhinoscriptsyntax as rs
def RHTest():
value = rs.GetString()
print(value)
if __name__ == '__main__':
RHTest()
Install the plug-in (.yak) and assign an alias AA with the macro _RHTest HelloWorld
Close the Rhino application completely and reopen it afterwards.
Run the alias AA that you assigned in step 2 (it does not behave properly).
Then run the same alias again (it now works as intended).
Observations
The first time the alias is run after starting Rhino it prints; “Unknown command: HelloWorld”. The second time the alias is run it correctly prints; “HelloWorld”.
Expected behavior
The alias should always print “HelloWorld”.
Video
(Observe all printed messages in the command history in the lower left corner)
@AMG The first time you run a command (published from script), it needs to load the languages that run that script. I suspect/can confirm that the progress bar is NOT showing that shows the load progress of languages.
Would you mind testing something for me real quick. Run your command in a fresh instance of Rhino, and wait for a few seconds. I think the prompt will show up but it takes a bit of time the first time. I made this ticket to fix the progress bar not showing
RH-83810 Published scripts do not show language load progressbar
The prompt shows up (after a delay), but when I assign the macro _RHTest HelloWorld to an alias, I want to automatically provide the value “HelloWorld” to the command implicitly each time the alias is executed. This fails the first time the alias is executed, probably because of the language loading you mentioned. Afterwards, it behaves and executes correctly.
Hi @eirannejad, I am seeing similar behavior on my end as well with a compiled command I’m calling “loadui”.
Previously I would load Grasshopper and have this command follow that action to then load the ui.
Now, what is happening is that it always says “unknown command: loadui” the first time but then works just fine if I run it again or type “loadui” directly in the command line.
Let me know if you need any files from me, thank you so much!
Okay I am pushing a fix for the missing progress bar. The fail-on-first-run is definitely a Rhino-mac-specific behaviour. I can not replicate this on Windows.
I found where the problem is with running the alias and so far I am pretty sure it is macOS specific. @michaelvollrath Would you mind sharing an example of this happening on Windows? I can not get Win to repeat this behaviour
Okay in further testing I believe it was a complex string sequence causing an escape character to trigger a command interruption… leading it to “look” very much like the behavior in this post but different…