algorithmic modeling for Rhino
Hi, I was wondering how one can programmatically invoke the "internalise" and "update" options found in the context menu of a referenced cluster.
I found an undocumented class property Grasshopper.Kernel.Special.GH_Cluster.Synchronisation that contains the state like e.g. "OutOfDate" or "NotReferenced".
Is "update" the same as invoking GH_Cluster.ReadGhClusterFile?
and
Is "internalise" the same is reading the internal document of the definition and referencing the component cluster document somehow to that? I've seen a byte array in the xml version of a definition that contains a referenced cluster component, which I presume is an internal copy of the content of the reference cluster file. However, I can't figure out how to get access to that.
In any case I'm stuck.
Tags:
GH_Synchronisation is an enum which lists all the possible synchronisation states a cluster can be in. The values are:
If the cluster is OutOfDate and the 'Update' menu is clicked, the following code runs:
Dim record As New GH_UndoRecord("Update Cluster")
For Each cluster As GH_Cluster In ClusterFamily()
record.AddAction(New GH_GenericObjectAction(cluster))
cluster.CreateFromFilePath(cluster.m_file.Path)
Next
RecordUndoEvent(record)
ExpireSolution(True)
Which means, in English:
If you're only looking to do this on a per-cluster basis and you don't care about undo, then the CreateFromFilePath() method is all you need.
CreateFromFilePath() eventually calls ReadClusterFile(), but it does one or two additional bookkeeping tasks, so you're better off calling the high level method rather than ReadClusterFile().
Dear David,
I was wondering what are the necessary steps needed to make a battery that would update all non-updated clusters inside a file. Ideally with a trigger button.
I have tried to make a VB battery with the code that you have provided but I am getting all sorts of errors. I am quite new to VB.
Do you have any suggestions?
When you say VB, are you talking a VB scripting component, or a VB project in Visual Studio?
David,
I mean a scripting component.
I will then make a user object out of it.
Its important to notice that in my definition I have Clusters inside of Clusters, I am not sure if this will have any implications.
David,
what I am asking is probability super easy to do.
Can you at least direct me in the right direction?
Thanks for your help.
The 'Internalise' menu runs the following code:
Dim newID As Guid = Guid.NewGuid()
Dim record As New GH_UndoRecord("Cluster Frabbing")
For Each cluster As GH_Cluster In ClusterFamily()
record.AddAction(New GH_ClusterReferenceAction(cluster))
record.AddAction(New GH_ClusterDocumentIdAction(cluster))cluster.DocumentId = newID
cluster.m_file.Path = Nothing
cluster.m_file.UpdateToCurrentFile()
Next
RecordUndoEvent(record)
Instances.InvalidateCanvas()
Which means, in English:
You can again get rid of the loop and the undo code if you only care about a single cluster.
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by