Curious
Curious
CC#
Created by Curious on 5/23/2023 in #help
❔ XML Read XML and save as dictionary
thank you
25 replies
CC#
Created by Curious on 5/23/2023 in #help
❔ XML Read XML and save as dictionary
makes sense to be fair
25 replies
CC#
Created by Curious on 5/23/2023 in #help
❔ XML Read XML and save as dictionary
Ohhh
25 replies
CC#
Created by Curious on 5/23/2023 in #help
❔ XML Read XML and save as dictionary
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Ribbon_Visibility_Preferences>
<Values key="Architecture" value="True" />
<Values key="Structure" value="False" />
<Values key="Steel" value="False" />
<Values key="thePrecastTab" value="False" />
<Values key="Systems" value="True" />
<Values key="Insert" value="True" />
<Values key="Annotate" value="True" />
<Values key="Analyze" value="True" />
<Values key="MassingSite" value="False" />
<Values key="Collaborate" value="False" />
<Values key="View" value="True" />
<Values key="Manage" value="True" />
<Values key="Home_Family" value="False" />
<Values key="Insert_AnnotationDetailModelMassConceptualProfileTrussFamily" value="False" />
<Values key="Annotate_ModelMassFamily" value="False" />
<Values key="View_Family" value="False" />
<Values key="Manage_Family" value="False" />
<Values key="Add-Ins" value="False" />
<Values key="Modify" value="True" />
<Values key="Second_Modify" value="False" />
<Values key="InPlaceModelFamilyTab" value="False" />
<Values key="InPlaceMassFamilyTab" value="False" />
<Values key="InPlaceZoneFamilyTab" value="False" />
<Values key="FamilyEditorTab" value="False" />
</Ribbon_Visibility_Preferences>
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Ribbon_Visibility_Preferences>
<Values key="Architecture" value="True" />
<Values key="Structure" value="False" />
<Values key="Steel" value="False" />
<Values key="thePrecastTab" value="False" />
<Values key="Systems" value="True" />
<Values key="Insert" value="True" />
<Values key="Annotate" value="True" />
<Values key="Analyze" value="True" />
<Values key="MassingSite" value="False" />
<Values key="Collaborate" value="False" />
<Values key="View" value="True" />
<Values key="Manage" value="True" />
<Values key="Home_Family" value="False" />
<Values key="Insert_AnnotationDetailModelMassConceptualProfileTrussFamily" value="False" />
<Values key="Annotate_ModelMassFamily" value="False" />
<Values key="View_Family" value="False" />
<Values key="Manage_Family" value="False" />
<Values key="Add-Ins" value="False" />
<Values key="Modify" value="True" />
<Values key="Second_Modify" value="False" />
<Values key="InPlaceModelFamilyTab" value="False" />
<Values key="InPlaceMassFamilyTab" value="False" />
<Values key="InPlaceZoneFamilyTab" value="False" />
<Values key="FamilyEditorTab" value="False" />
</Ribbon_Visibility_Preferences>
25 replies
CC#
Created by Curious on 5/23/2023 in #help
❔ XML Read XML and save as dictionary
private const string RibbonVisPref = "Ribbon_Visibility_Preferences";
25 replies
CC#
Created by Curious on 5/23/2023 in #help
❔ XML Read XML and save as dictionary
private const string StoredDataFile = "C:\\ProgramData\\SDS_TOOLS\\RibbonPreferences.xml";
25 replies
CC#
Created by Curious on 5/23/2023 in #help
❔ XML Read XML and save as dictionary
public static Dictionary<string, bool> ReadFromXML(string tagToRead)
{
Dictionary<string, bool> outDict = new Dictionary<string, bool>();
//look for the tag tagtoread in the XML tree, then return all values in that tag as a dictionary
try
{
XmlDocument xml = new XmlDocument();
xml.Load(StoredDataFile);
xml.LoadXml(tagToRead);

XmlNodeList xnList = xml.SelectNodes(tagToRead);
foreach (XmlNode xn in xnList)
{
//get value and get bool and convert to dict
string key = xn.Attributes["key"].Value;
bool value = Convert.ToBoolean(xn.Attributes["value"].Value);

outDict.Add(key, value);
}
return outDict;
}
catch (Exception ex)
{
Autodesk.Revit.UI.TaskDialog.Show("Read XML Error", ex.Message);
return null;
}

}
public static Dictionary<string, bool> ReadFromXML(string tagToRead)
{
Dictionary<string, bool> outDict = new Dictionary<string, bool>();
//look for the tag tagtoread in the XML tree, then return all values in that tag as a dictionary
try
{
XmlDocument xml = new XmlDocument();
xml.Load(StoredDataFile);
xml.LoadXml(tagToRead);

XmlNodeList xnList = xml.SelectNodes(tagToRead);
foreach (XmlNode xn in xnList)
{
//get value and get bool and convert to dict
string key = xn.Attributes["key"].Value;
bool value = Convert.ToBoolean(xn.Attributes["value"].Value);

outDict.Add(key, value);
}
return outDict;
}
catch (Exception ex)
{
Autodesk.Revit.UI.TaskDialog.Show("Read XML Error", ex.Message);
return null;
}

}
25 replies
CC#
Created by Curious on 5/23/2023 in #help
❔ XML Read XML and save as dictionary
25 replies
CC#
Created by Curious on 5/23/2023 in #help
❔ XML Read XML and save as dictionary
No still produces error Pref is an unexpected token. The expected token is = Line 2, position 20. and returns null
25 replies
CC#
Created by Curious on 5/23/2023 in #help
❔ XML Read XML and save as dictionary
Yes Hi
25 replies
CC#
Created by Curious on 5/23/2023 in #help
❔ XML Read XML and save as dictionary
Awesome - Thank you will test it now 😄
25 replies
CC#
Created by Curious on 5/23/2023 in #help
❔ XML Read XML and save as dictionary
Values the same then, i.e Archi Tecture would be invalid?
25 replies
CC#
Created by Curious on 5/23/2023 in #help
❔ XML Read XML and save as dictionary
That simple?
25 replies
CC#
Created by Curious on 5/23/2023 in #help
❔ XML Read XML and save as dictionary
Ribbon Visibility Preferences to Ribbon_Visibility_Preferences?
25 replies
CC#
Created by Curious on 5/23/2023 in #help
❔ XML Read XML and save as dictionary
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Ribbon Visibility Preferences>
<Values key="Architecture" value="True" />
<Values key="Structure" value="False" />
<Values key="Steel" value="False" />
<Values key="thePrecastTab" value="False" />
</Ribbon Visibility Preferences>
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Ribbon Visibility Preferences>
<Values key="Architecture" value="True" />
<Values key="Structure" value="False" />
<Values key="Steel" value="False" />
<Values key="thePrecastTab" value="False" />
</Ribbon Visibility Preferences>
This is an example XML doc
25 replies
CC#
Created by Curious on 3/28/2023 in #help
✅ Win Form Event Handlers question
Yeah thought it might just be easier to generate my own, thanks for the second opinion!
5 replies
CC#
Created by Curious on 1/11/2023 in #help
❔ different variable type depending on condition of IF statement
Ah Yes I see, perfect thank you!
ISelectionFilter elmFilter = null;
if (FilterSelected == 0)
{
elmFilter = new Helpers.ElementFilterTerminals();
}
if (FilterSelected == 1)
{
elmFilter = new Helpers.ElementFilterDuctwork();
}
ISelectionFilter elmFilter = null;
if (FilterSelected == 0)
{
elmFilter = new Helpers.ElementFilterTerminals();
}
if (FilterSelected == 1)
{
elmFilter = new Helpers.ElementFilterDuctwork();
}
12 replies
CC#
Created by Curious on 1/11/2023 in #help
❔ different variable type depending on condition of IF statement
Unless I misunderstood what you meant for me to do..?
12 replies
CC#
Created by Curious on 1/11/2023 in #help
❔ different variable type depending on condition of IF statement
12 replies
CC#
Created by Curious on 1/11/2023 in #help
❔ different variable type depending on condition of IF statement
12 replies