예제 #1
0
		public void increaseValueParameter_Update()
		{			
			UIDocument uiDoc = this.ActiveUIDocument;
			Document doc = uiDoc.Document;

			string prefix = "9B";
			
			int beginNumber = 1;
			
			string suffix = "";
			
			
			string parameterName = "INNO_Ten-CK";
			

			IncreaseParameterForm myFormIncreaseParameter = new IncreaseParameterForm();
			// Add list parameter to cb
			myFormIncreaseParameter.Show();
			myFormIncreaseParameter.TopMost = true;
			
			//if the user hits cancel just drop out of macro
		    if(myFormIncreaseParameter.DialogResult == System.Windows.Forms.DialogResult.Cancel)
		    {
		    	//else do all this :)    
		    	//myFormIncreaseParameter.Close();
		    	return;
		    }
		    
		    if(myFormIncreaseParameter.DialogResult == System.Windows.Forms.DialogResult.OK)
		    {
//		    	parameterName = myFormIncreaseParameter.paraName_Tb.Text;
//		    	
//		    	prefix = myFormIncreaseParameter.Pre_Tb.Text;
//		    	beginNumber = Convert.ToInt32( myFormIncreaseParameter.startNum_Tb.Text);
//		    	suffix = myFormIncreaseParameter.Suf_Tb.Text;
		    	//myFormIncreaseParameter.Close();
		    }
		
			
			
			
			while (true) 
			
			{
				// Load setting
				
				
				parameterName = valueOfSetting(@"D:\Revit Setting\RevitSetting.set","INCREASE_PARA_NANE");
				prefix = valueOfSetting(@"D:\Revit Setting\RevitSetting.set","INCREASE_PARA_PRE");
				
				
				
				beginNumber = Convert.ToInt32((valueOfSetting(@"D:\Revit Setting\RevitSetting.set","INCREASE_PARA_START")));
				suffix = valueOfSetting(@"D:\Revit Setting\RevitSetting.set","INCREASE_PARA_SUF");
					
				
				
				List<Reference> myListRef = uiDoc.Selection.PickObjects(ObjectType.Element, "Select Elements...") as List<Reference>;

				using (Transaction trans = new Transaction(doc, "Increase Parameter..."))
				{
					trans.Start();
					
					foreach (Reference myRef in myListRef) 
					{
						Element myElem = doc.GetElement(myRef);
						Parameter myParameter = myElem.LookupParameter(parameterName);
	                    if(myParameter == null)
	                    {
	                        TaskDialog.Show("Error!!", "Has no parpation name: " + parameterName);
	                    }
	                    
	                    else
	                    {
	                    	myParameter.Set(prefix + beginNumber.ToString() + suffix);
	                    
	                    }

					}
					trans.Commit();
				}
            	beginNumber++;
            	
			changeSetting(@"D:\Revit Setting\RevitSetting.set","INCREASE_PARA_START",
            	              beginNumber.ToString());
			}
		
		}
예제 #2
0
		public void increaseValueParameter()
		{			
			UIDocument uiDoc = this.ActiveUIDocument;
			Document doc = uiDoc.Document;

			int methodIndex = 0;
			
			string prefix = "9B";
			
			int beginNumber = 1;
			
			string suffix = "";
			
			bool isDecrease = false;
			
			string parameterName = "INNO_Ten-CK";
			
			using (IncreaseParameterForm myFormIncreaseParameter = new IncreaseParameterForm()) 
			
			{
				// Add list parameter to cb
				myFormIncreaseParameter.ShowDialog();
				
				//if the user hits cancel just drop out of macro
			    if(myFormIncreaseParameter.DialogResult == System.Windows.Forms.DialogResult.Cancel)
			    {
			    	//else do all this :)    
			    	myFormIncreaseParameter.Close();
			    	return;
			    }
			    
			    if(myFormIncreaseParameter.DialogResult == System.Windows.Forms.DialogResult.OK)
			    {
			    	isDecrease = myFormIncreaseParameter.isDecreaseChecked;
			    	
			    	methodIndex = myFormIncreaseParameter.method;
			    	
			    	parameterName = myFormIncreaseParameter.paraName_Tb.Text;
			    	
			    	prefix = myFormIncreaseParameter.Pre_Tb.Text;
			    	beginNumber = Convert.ToInt32( myFormIncreaseParameter.startNum_Tb.Text);
			    	suffix = myFormIncreaseParameter.Suf_Tb.Text;
			    	myFormIncreaseParameter.Close();
			    }	
			}

			string myStatus = "Next Name of Element: " + prefix + beginNumber.ToString() + suffix;
			while (true) 
			
			{
				// Method 1:
				if (methodIndex == 1) 
				{
					Reference myRef = uiDoc.Selection.PickObject(ObjectType.Element, myStatus);
	
					using (Transaction trans = new Transaction(doc, "Increase Parameter..."))
					{
						trans.Start();

						Element myElem = doc.GetElement(myRef);
						Parameter myParameter = myElem.LookupParameter(parameterName);
	                    if(myParameter == null)
	                    {
	                        TaskDialog.Show("Error!!", "Has no parameter name: " + parameterName);
	                    }
	                    
	                    else
	                    {
	                    	myParameter.Set(prefix + beginNumber.ToString() + suffix);
	                    }

						trans.Commit();
					}
					
					if(isDecrease)
					{
						beginNumber--;
					}
					else
					{
		            	beginNumber++;
					}

					changeSetting(@"D:\Revit Setting\RevitSetting.set","INCREASE_PARA_START",
	              	beginNumber.ToString());
	            	myStatus = "Next Name of Element: " + prefix + beginNumber.ToString() + suffix;
				}					
				
				// Method 2	

				if (methodIndex == 2) 
				{
					List<Reference> myListRef = uiDoc.Selection.PickObjects(ObjectType.Element, myStatus) as List<Reference>;
	
					using (Transaction trans = new Transaction(doc, "Increase Parameter..."))
					{
						trans.Start();
						foreach (Reference myRef in myListRef) 
						{
							Element myElem = doc.GetElement(myRef);
							Parameter myParameter = myElem.LookupParameter(parameterName);
		                    if(myParameter == null)
		                    {
		                        TaskDialog.Show("Error!!", "Has no parameter name: " + parameterName);
		                    }
		                    
		                    else
		                    {
		                    	myParameter.Set(prefix + beginNumber.ToString() + suffix);
		                    }
						}
						trans.Commit();
					}
					
					
					if(isDecrease)
					{
						beginNumber--;
					}
					else
					{
		            	beginNumber++;
					}
					
					changeSetting(@"D:\Revit Setting\RevitSetting.set","INCREASE_PARA_START",
	              	beginNumber.ToString());
	            	myStatus = "Next Name of Element: " + prefix + beginNumber.ToString() + suffix;
				}
				
				// Method 3	

				if (methodIndex == 3) 
				{

					List<Reference> myListRef = uiDoc.Selection.PickObjects(ObjectType.Element, myStatus) as List<Reference>;
	
					using (Transaction trans = new Transaction(doc, "Increase Parameter..."))
					{
						trans.Start();
						foreach (Reference myRef in myListRef) 
						{
							Element myElem = doc.GetElement(myRef);
							Parameter myParameter = myElem.LookupParameter(parameterName);
		                    if(myParameter == null)
		                    {
		                        TaskDialog.Show("Error!!", "Has no parameter name: " + parameterName);
		                    }
		                    
		                    else
		                    {
		                    	myParameter.Set(prefix + beginNumber.ToString() + suffix);
		                    	
        						if(isDecrease)
									{
										beginNumber--;
									}
									else
									{
						            	beginNumber++;
									}
		                    }
						}
						trans.Commit();
					}

					changeSetting(@"D:\Revit Setting\RevitSetting.set","INCREASE_PARA_START",
	              	beginNumber.ToString());
	            	myStatus = "Next Name of Element: " + prefix + beginNumber.ToString() + suffix;
				}	
			}
		}