public override bool Read(GH_IO.Serialization.GH_IReader reader) { // First read our own field. EvenOdd = reader.GetBoolean("EvenOdd"); // Then call the base class implementation. return base.Read(reader); }
public override bool Read(GH_IO.Serialization.GH_IReader reader) { string newfilepath = ""; reader.TryGetString("filepath", ref newfilepath); SetFilepath(newfilepath); return base.Read(reader); }
public override bool Write(GH_IO.Serialization.GH_IWriter writer) { // Add the family name and type name writer.SetString("FamilyName", FamilyName); writer.SetString("TypeName", TypeName); writer.SetString("Category", Category); writer.SetInt32("CategoryId", CategoryId); for (int i = 0; i < inputParameters.Count; i++) { try { RevitParameter rp = inputParameters[i]; writer.SetString("ParameterName" + i.ToString(CultureInfo.InvariantCulture), rp.ParameterName); writer.SetString("StorageType" + i.ToString(CultureInfo.InvariantCulture), rp.StorageType); writer.SetBoolean("IsType" + i.ToString(CultureInfo.InvariantCulture), rp.IsType); } catch (Exception exception) { Debug.WriteLine(exception.Message); } } return base.Write(writer); }
public override bool Read(GH_IO.Serialization.GH_IReader reader) { FamilyName = reader.GetString("FamilyName"); TypeName = reader.GetString("TypeName"); Category = reader.GetString("Category"); CategoryId = reader.GetInt32("CategoryId"); bool test = true; int i = 0; List<RevitParameter> parameters = new List<RevitParameter>(); while (test) { RevitParameter rp = new RevitParameter(); try { rp.ParameterName = reader.GetString("ParameterName" + i.ToString(CultureInfo.InvariantCulture)); rp.StorageType = reader.GetString("StorageType" + i.ToString(CultureInfo.InvariantCulture)); rp.IsType = reader.GetBoolean("IsType" + i.ToString(CultureInfo.InvariantCulture)); parameters.Add(rp); } catch { test = false; } i++; } InputParams = parameters; if (inputParameters.Count > 0) { SyncInputs(); } return base.Read(reader); }
public override bool Read(GH_IO.Serialization.GH_IReader reader) { Operation = (ClipType)reader.GetInt32("Operation"); FillType = (PolyFillType)reader.GetInt32("FillType"); return base.Read(reader); }
public override bool Write(GH_IO.Serialization.GH_IWriter writer) { writer.SetInt32("Operation", (int)Operation); writer.SetInt32("FillType", (int)FillType); return base.Write(writer); }
public override bool Read(GH_IO.Serialization.GH_IReader reader) { elements = new List<string>(); bool keepMoving = true; int i = 0; while (keepMoving) { try { string value = reader.GetString("Element", i); elements.Add(value); i++; } catch { keepMoving = false; } } return base.Read(reader); }
public override bool Read(GH_IO.Serialization.GH_IReader reader) { int val = -1; if (reader.TryGetInt32(TargetDocIdentifier, ref val)) DocStorageMode = (DocStorage)val; if (!Enum.IsDefined(typeof(DocStorage), DocStorageMode)) DocStorageMode = DocStorage.InGrasshopperMemory; return base.Read(reader); }
public override bool Read(GH_IO.Serialization.GH_IReader reader) { reader.TryGetString("path", ref selectedFolder); return base.Read(reader); }
public override bool Read(GH_IO.Serialization.GH_IReader reader) { // First read our own field. if (reader.ItemExists("ComponentName")) { this.customNameSet = true; this.ComponentName = reader.GetString("ComponentName"); } // Then call the base class implementation. return base.Read(reader); }
public override bool Write(GH_IO.Serialization.GH_IWriter writer) { bool rc = base.Write(writer); writer.SetBoolean(HideInputIdentifier, !CodeInputVisible); if (!CodeInputVisible) writer.SetString(CodeInputIdentifier, CodeInput); writer.SetBoolean(HideOutputIdentifier, HideCodeOutput); return rc; }
public override bool Read(GH_IO.Serialization.GH_IReader reader) { // 8 Aug. 2012 // There are a couple of "hacks" in here to get IO code to work properly. // I'll discuss fixes for this so we can skip over the code in future // versions of grasshopper bool perform_hacks = this is IGH_VarParamComponent; if (perform_hacks) { // only perform these hacks on 0.9.6 and below. Assuming that this // will get fixed in the very next GH release var version = Grasshopper.Versioning.Version; if (version.major > 0 || version.minor > 9 || (version.minor == 9 && version.revision > 6)) perform_hacks = false; } if( perform_hacks ) { // Hack #1 // When deserializing, this component is constructed and the I can't tell // that this component was created for deserializing from disk and the // "AddDefaultInput" / "AddDefaultOutput" functions are called. The low level // parameter reading code skips reading of params when they already exists // (see Read_IGH_VarParamParamList in GH_ComponentParamServer.vb) // ... If (i<params.Count) Then Continue For // Clear out the default input parameters so the GH variable // parameter reader doesn't get hosed for (int i = Params.Input.Count - 1; i >= 0; i--) Params.UnregisterParameter(Params.Input[0]); for (int i = Params.Output.Count - 1; i >= 0; i--) Params.UnregisterParameter(Params.Output[0]); } bool rc = base.Read(reader); if (perform_hacks) { // Hack #2 // The IO code in checks to see if "Access" exists when it looks like // it should be checking if "Access" at index exists // (see Read_IGH_VarParamParamList in GH_ComponentParamServer.vb) // ...If( reader.ItemExists("Access")) Then // probably should be // ...If( reader.ItemExists("Access", i)) Then // // Working around this issue by manually digging through the chuncks if (reader.ChunkCount > 1) { var chunk = reader.Chunks[1]; for (int i = 0; i < chunk.ItemCount; i++) { var item = chunk.Items[i]; if (item != null && string.Compare(item.Name, "Access", StringComparison.InvariantCulture) == 0) { int index = item.Index; if (index >= 0 && index < Params.Input.Count) { int access = item._int32; if (1 == access) Params.Input[index].Access = GH_ParamAccess.list; else if (2 == access) Params.Input[index].Access = GH_ParamAccess.tree; } } } } } bool hideInput = false; if (reader.TryGetBoolean(HideInputIdentifier, ref hideInput)) CodeInputVisible = !hideInput; if (!CodeInputVisible) { string code = null; if (reader.TryGetString(CodeInputIdentifier, ref code)) CodeInput = code; } bool hideOutput = false; if (reader.TryGetBoolean(HideOutputIdentifier, ref hideOutput)) HideCodeOutput = hideOutput; if (HideCodeOutput) Params.Output.RemoveAt(0); // Dynamic input fix for existing scripts // Always assign DynamicHint or Grasshopper // will set Line and not LineCurve, etc... if (Params != null && Params.Input != null) { for (int i = CodeInputVisible ? 1 : 0; i < Params.Input.Count; i++) { var p = Params.Input[i] as Param_ScriptVariable; if (p != null) { FixGhInput(p, false); if (p.TypeHint == null) { p.TypeHint = p.Hints[0]; } } } } return rc; }
public override bool Write(GH_IO.Serialization.GH_IWriter writer) { // First add our own field. writer.SetBoolean("EvenOdd", EvenOdd); // Then call the base class implementation. return base.Write(writer); }
//public override void AddedToDocument(GH_Document document){ Menu_SetFilepathClicked(new object(), new EventArgs());} public override bool Write(GH_IO.Serialization.GH_IWriter writer) { writer.SetString("filepath", this.filepath); return base.Write(writer); }
public override bool Read(GH_IO.Serialization.GH_IReader reader) { // 2013 Oct 8 - Giulio // Removing all hacks and making this work properly from Gh 0.9.61 onwards // The logic is this: this component ALWAYS gets constructed without "code" & with "out". // Then, when they are not necessary, these are added or removed. // RegisterInput/Output must always insert the original amount of items. if (reader.ItemExists(ID_EditorLocation)) DefaultEditorLocation = reader.GetDrawingPoint(ID_EditorLocation); if (reader.ItemExists(ID_EditorSize)) DefaultEditorSize = reader.GetDrawingSize(ID_EditorSize); bool hideInput = true; if (reader.TryGetBoolean(ID_HideInput, ref hideInput)) HiddenCodeInput = hideInput; bool hideOutput = false; if (reader.TryGetBoolean(ID_HideOutput, ref hideOutput)) HiddenOutOutput = hideOutput; if (hideInput) if (!reader.TryGetString(ID_CodeInput, ref m_inner_codeInput)) m_inner_codeInput = string.Empty; bool rc = base.Read(reader); // Dynamic input fix for existing scripts // Always assign DynamicHint or Grasshopper // will set Line and not LineCurve, etc... if (Params != null && Params.Input != null) { for (int i = HiddenCodeInput ? 1 : 0; i < Params.Input.Count; i++) { var p = Params.Input[i] as Param_ScriptVariable; if (p != null) { FixGhInput(p, false); if (p.TypeHint == null) { p.TypeHint = p.Hints[0]; } } } } return rc; }
public override bool Write(GH_IO.Serialization.GH_IWriter writer) { // First add our own field. if (this.customNameSet) writer.SetString("ComponentName", this.ComponentName); // Then call the base class implementation. return base.Write(writer); }
public override bool Write(GH_IO.Serialization.GH_IWriter writer) { bool rc = base.Write(writer); writer.SetBoolean(ID_HideInput, HiddenCodeInput); if (HiddenCodeInput) writer.SetString(ID_CodeInput, Code); writer.SetBoolean(ID_HideOutput, HiddenOutOutput); //update if possible and save editor location { Form editor; if (Attributes.TryGetEditor(out editor)) { DefaultEditorLocation = editor.Location; DefaultEditorSize = editor.Visible ? editor.Size : editor.RestoreBounds.Size; } } if (DefaultEditorLocation != null) { writer.SetDrawingPoint(ID_EditorLocation, DefaultEditorLocation.Value); writer.SetDrawingSize(ID_EditorSize, DefaultEditorSize); } return rc; }
public bool Read(GH_IO.Serialization.GH_IReader reader) { throw new NotImplementedException(); }
public override bool Write(GH_IO.Serialization.GH_IWriter writer) { writer.SetString("path", this.selectedFolder); return base.Write(writer); }
public bool Write(GH_IO.Serialization.GH_IWriter writer) { throw new NotImplementedException(); }
public override bool Write(GH_IO.Serialization.GH_IWriter writer) { if (!Enum.IsDefined(typeof(DocStorage), DocStorageMode)) DocStorageMode = DocStorage.InGrasshopperMemory; writer.SetInt32(TargetDocIdentifier, (int)DocStorageMode); return base.Write(writer); }
public override bool Write(GH_IO.Serialization.GH_IWriter writer) { // write the information to the component. for (int i = 0; i < elements.Count; i++) { writer.SetString("Element", i, elements[i]); } return base.Write(writer); }