<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Add/Set a System Pipes Custom Parameters in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/add-set-a-system-pipes-custom-parameters/m-p/4408713#M78786</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to add a custom parameter to a System Pipe? I have successfully added many shared parameters to the shared parameter file. And I am also able to set a FamilyInstances' shared parameter (called 'Chainage').&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I am unable to set a System Pipes shared parameter 'Chainage'. It throws the exception:&lt;/P&gt;&lt;P&gt;Object reference not set to an instance of an object&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This error has occurred before when I tried to set a parameter that doesn't exist. Is it possible to add and set a custom parameter to a System Pipe? If so how do I do it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My below code successfully registers some shared parameters, successfully sets a FamilyInstance's shared param but fails when I try to set a System Pipes same shared param:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;public static FamilyInstance createPit(Document doc, XmlNode pitNode, XmlNamespaceManager nsmgr)
{
	if (!setupSharedParameters(doc))
		return null;

	// Create family instance and set param: Succeeds
	double x            = getXmlNodeDouble(pitNode, "ns:x", nsmgr);
	double y            = getXmlNodeDouble(pitNode, "ns:y", nsmgr);
	double z            = getXmlNodeDouble(pitNode, "ns:z", nsmgr);
	FamilyInstance instance = doc.Create.NewFamilyInstance(new XYZ(x, y, z), pitSymbol, StructuralType.NonStructural);
	instance.get_Parameter("Road Name").Set("IRULE");
	
	// Create System pipe and set param: Fails
	Pipe pipe = doc.Create.NewPipe(new XYZ(x, y, z), new XYZ(x+10, y, z), pipeType);&lt;BR /&gt;        // Note pipe exists and is not null
	pipe.get_Parameter("Road Name").Set("IRULE"); // ERROR OCCURS HERE
	return instance;
}

public static bool setupSharedParameters(Document doc)
{
	try
	{
		if (SHARED_PARAMS_SETUP)
			return SHARED_PARAMS_SETUP;

		//prepare shared parameter file
		String path         = Assembly.GetExecutingAssembly().Location;
		int index           = path.LastIndexOf("\\");
		String newPath      = path.Substring(0, index);
		newPath            += "\\RevitParameters.txt";
		
		if (File.Exists(newPath))
			File.Delete(newPath);

		FileStream fs = File.Create(newPath);
		fs.Close();
		doc.Application.SharedParametersFilename = newPath;

		//Open shared parameter file
		DefinitionFile parafile = doc.Application.OpenSharedParameterFile();

		//get walls category
		Category wallCat = doc.Settings.Categories.get_Item(BuiltInCategory.OST_PlumbingFixtures); //  .OST_Walls);
		CategorySet categories = doc.Application.Create.NewCategorySet();
		categories.Insert(wallCat);

		InstanceBinding binding = doc.Application.Create.NewInstanceBinding(categories);

		//Create a group
		DefinitionGroup apiGroup = parafile.Groups.Create("APIGroup");

		//Create a visible "VisibleParam" of text type.
		BindingMap bindingMap = doc.ParameterBindings;
		Definition visibleParamDef = apiGroup.Definitions.Create("Type", ParameterType.Text, true);
		bindingMap.Insert(visibleParamDef, binding);
		visibleParamDef = apiGroup.Definitions.Create("Chainage", ParameterType.Number, true);
		bindingMap.Insert(visibleParamDef, binding);
		visibleParamDef = apiGroup.Definitions.Create("Road Name", ParameterType.Text, true);
		bindingMap.Insert(visibleParamDef, binding);
		
		SHARED_PARAMS_SETUP = true;
		return SHARED_PARAMS_SETUP;
	}
	catch (Exception e)
	{
		return false;
	}
}

&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 08 Sep 2013 23:52:10 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2013-09-08T23:52:10Z</dc:date>
    <item>
      <title>Add/Set a System Pipes Custom Parameters</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/add-set-a-system-pipes-custom-parameters/m-p/4408713#M78786</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to add a custom parameter to a System Pipe? I have successfully added many shared parameters to the shared parameter file. And I am also able to set a FamilyInstances' shared parameter (called 'Chainage').&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I am unable to set a System Pipes shared parameter 'Chainage'. It throws the exception:&lt;/P&gt;&lt;P&gt;Object reference not set to an instance of an object&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This error has occurred before when I tried to set a parameter that doesn't exist. Is it possible to add and set a custom parameter to a System Pipe? If so how do I do it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My below code successfully registers some shared parameters, successfully sets a FamilyInstance's shared param but fails when I try to set a System Pipes same shared param:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;public static FamilyInstance createPit(Document doc, XmlNode pitNode, XmlNamespaceManager nsmgr)
{
	if (!setupSharedParameters(doc))
		return null;

	// Create family instance and set param: Succeeds
	double x            = getXmlNodeDouble(pitNode, "ns:x", nsmgr);
	double y            = getXmlNodeDouble(pitNode, "ns:y", nsmgr);
	double z            = getXmlNodeDouble(pitNode, "ns:z", nsmgr);
	FamilyInstance instance = doc.Create.NewFamilyInstance(new XYZ(x, y, z), pitSymbol, StructuralType.NonStructural);
	instance.get_Parameter("Road Name").Set("IRULE");
	
	// Create System pipe and set param: Fails
	Pipe pipe = doc.Create.NewPipe(new XYZ(x, y, z), new XYZ(x+10, y, z), pipeType);&lt;BR /&gt;        // Note pipe exists and is not null
	pipe.get_Parameter("Road Name").Set("IRULE"); // ERROR OCCURS HERE
	return instance;
}

public static bool setupSharedParameters(Document doc)
{
	try
	{
		if (SHARED_PARAMS_SETUP)
			return SHARED_PARAMS_SETUP;

		//prepare shared parameter file
		String path         = Assembly.GetExecutingAssembly().Location;
		int index           = path.LastIndexOf("\\");
		String newPath      = path.Substring(0, index);
		newPath            += "\\RevitParameters.txt";
		
		if (File.Exists(newPath))
			File.Delete(newPath);

		FileStream fs = File.Create(newPath);
		fs.Close();
		doc.Application.SharedParametersFilename = newPath;

		//Open shared parameter file
		DefinitionFile parafile = doc.Application.OpenSharedParameterFile();

		//get walls category
		Category wallCat = doc.Settings.Categories.get_Item(BuiltInCategory.OST_PlumbingFixtures); //  .OST_Walls);
		CategorySet categories = doc.Application.Create.NewCategorySet();
		categories.Insert(wallCat);

		InstanceBinding binding = doc.Application.Create.NewInstanceBinding(categories);

		//Create a group
		DefinitionGroup apiGroup = parafile.Groups.Create("APIGroup");

		//Create a visible "VisibleParam" of text type.
		BindingMap bindingMap = doc.ParameterBindings;
		Definition visibleParamDef = apiGroup.Definitions.Create("Type", ParameterType.Text, true);
		bindingMap.Insert(visibleParamDef, binding);
		visibleParamDef = apiGroup.Definitions.Create("Chainage", ParameterType.Number, true);
		bindingMap.Insert(visibleParamDef, binding);
		visibleParamDef = apiGroup.Definitions.Create("Road Name", ParameterType.Text, true);
		bindingMap.Insert(visibleParamDef, binding);
		
		SHARED_PARAMS_SETUP = true;
		return SHARED_PARAMS_SETUP;
	}
	catch (Exception e)
	{
		return false;
	}
}

&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Sep 2013 23:52:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/add-set-a-system-pipes-custom-parameters/m-p/4408713#M78786</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-09-08T23:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: Add/Set a System Pipes Custom Parameters</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/add-set-a-system-pipes-custom-parameters/m-p/4409107#M78787</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;Yes you can have shared parameter for pipes. You just need to use BuiltInCategory.OST_PipeCurves category in the binding.</description>
      <pubDate>Mon, 09 Sep 2013 05:16:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/add-set-a-system-pipes-custom-parameters/m-p/4409107#M78787</guid>
      <dc:creator>ollikat</dc:creator>
      <dc:date>2013-09-09T05:16:33Z</dc:date>
    </item>
    <item>
      <title>Re: Add/Set a System Pipes Custom Parameters</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/add-set-a-system-pipes-custom-parameters/m-p/4409205#M78788</link>
      <description>&lt;P&gt;Thanks for the reply &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I altered my code so that the plumbing fixture category is used in the binding. And then finally altered/set a pipes params but the parameter is not appearing in the properties tab (when I select the pipe).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: the shared parameters are visible and the error I mentioned above still occurs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas what I am doing wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;public static bool setupSharedParameters(Document doc)
{
	try
	{
		if (SHARED_PARAMS_SETUP)
			return SHARED_PARAMS_SETUP;

		//prepare shared parameter file
		String path         = Assembly.GetExecutingAssembly().Location;
		int index           = path.LastIndexOf("\\");
		String newPath      = path.Substring(0, index);
		newPath            += "\\RevitParameters.txt";
		
		if (File.Exists(newPath))
			File.Delete(newPath);

		FileStream fs = File.Create(newPath);
		fs.Close();
		doc.Application.SharedParametersFilename = newPath;

		//Open shared parameter file
		DefinitionFile parafile = doc.Application.OpenSharedParameterFile();

		Category plumbCat       = doc.Settings.Categories.get_Item(BuiltInCategory.OST_PlumbingFixtures);
		&lt;STRONG&gt;Category pipeCat        = doc.Settings.Categories.get_Item(BuiltInCategory.OST_PipeCurves);&lt;/STRONG&gt;
		CategorySet categories  = doc.Application.Create.NewCategorySet();
		//categories.Insert(plumbCat);
		&lt;STRONG&gt;categories.Insert(pipeCat);&lt;/STRONG&gt;

		InstanceBinding binding = doc.Application.Create.NewInstanceBinding(categories);

		//Create a group
		DefinitionGroup apiGroup = parafile.Groups.Create("APIGroup");

		//Create a visible "VisibleParam" of text type.
		BindingMap bindingMap = doc.ParameterBindings;
		Definition visibleParamDef = apiGroup.Definitions.Create("Type", ParameterType.Text, true);
		bindingMap.Insert(visibleParamDef, binding);
		visibleParamDef = apiGroup.Definitions.Create("Name", ParameterType.Text, true);
		bindingMap.Insert(visibleParamDef, binding);
		SHARED_PARAMS_SETUP = true;
		return SHARED_PARAMS_SETUP;
	}
	catch (Exception e)
	{
		return false;
	}
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Sep 2013 05:50:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/add-set-a-system-pipes-custom-parameters/m-p/4409205#M78788</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-09-09T05:50:15Z</dc:date>
    </item>
    <item>
      <title>Re: Add/Set a System Pipes Custom Parameters</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/add-set-a-system-pipes-custom-parameters/m-p/4409633#M78789</link>
      <description>Actually there error I get is different. The error is:&lt;BR /&gt;&lt;BR /&gt;This element does not support assignment of a user specified-name</description>
      <pubDate>Mon, 09 Sep 2013 06:18:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/add-set-a-system-pipes-custom-parameters/m-p/4409633#M78789</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-09-09T06:18:03Z</dc:date>
    </item>
  </channel>
</rss>

