When using the definition from here:
How can I make sure the output ghpy has the same GUID so that I don’t get multiple components of the same thing added to the ribbon?
When using the definition from here:
How can I make sure the output ghpy has the same GUID so that I don’t get multiple components of the same thing added to the ribbon?
These are rules provided by the Grasshopper SDK: they are the same for C#, Vb.Net and Python GHPYs.
When you publish your first version, you choose (or get automatically assigned) your Assembly.GUID and Component.GUID. Only one assembly per id can be loaded at any time in Grasshopper.
When it’s time to upgrade a GHPY, you need to use the ‘Advanced compilation mode’ to set your original Assembly.GUID and Component.GUID. Also, the amount of inputs and outputs, and their types, cannot change. The assembly name should not change. Basically, only the behavior should change.
If these rules are kept, the old components get serialized into the new ones.
I hope this helps,
Giulio
–
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com
The thing is that these Assembly.GUID and Component.GUID inside that compiling.gh are automatically generated I cannot influence it to put my own GUID.
I tried providing my own GUID as input like so:
def generateCode(ID):
doc = ghenv.Component.OnPingDocument()
if not doc: return
component = doc.FindComponent(ID)
if not component: return
settings = GhPython.Assemblies.ComponentGenerationParams(component)
settings.Name = zName
settings.Nickname = zNickname
settings.Description = zDescription
settings.Category = zCategory
settings.Subcategory = zSubCategory
settings.Id = zGUID
code = GhPython.Assemblies.CodeGeneration.GenerateComponentCode(component, settings, randomIds=True)
code += "\n\n"
settings = GhPython.Assemblies.AssemblyGenerationParams(component)
settings.Author = zAuthor
code += GhPython.Assemblies.CodeGeneration.GenerateAssemblyCode(component, settings, randomIds=True)
return settings, code
assemblySettings, code = generateCode(ID)
But it didn’t work, a random one was generated.
oh, I think I saw my own mistake. The inputs of the components cannot be used inside the def
without self.
in front right?
Well, randomIds=True
makes sure that the ID is always a new one.
Also… when I suggestion that you use ‘Advanced compilation mode/Copy compilable code’, I mean that you use Title 2 (2. Advanced compiling) in Tutorial: creating a Grasshopper component with the Python GHPY compiler. Please follow those instructions. There’s no need to write a meta-component when you are trying to get a basic one to work properly.