Create and apply arrowhead type

Create and apply arrowhead type

will.wydock
Advocate Advocate
1,950 Views
4 Replies
Message 1 of 5

Create and apply arrowhead type

will.wydock
Advocate
Advocate

Hi,

I had an idea to create a routine that create a standard tick mark and and apply it to all dimension styles. Does the API have the option to create a new arrowhead/tick mark? I could not find a way to filter out the arrowhead to move forward on this.

 

Any help is greatly appreciated

0 Likes
1,951 Views
4 Replies
Replies (4)
Message 2 of 5

jeremy_tammik
Alumni
Alumni

To research how this might be achieved programmatically, I would recommend starting off with the standard research approach to find a Revit API solution: 

 

https://thebuildingcoder.typepad.com/blog/2017/01/virtues-of-reproduction-research-mep-settings-onto...

 

Check how to achieve the desired result manually, e.g., searching for something like 'revit dimension style create a new arrowhead tick mark': 

 

https://duckduckgo.com/?q=revit+dimension+style+create+a+new+arrowhead+tick+mark

 

Analyse the properties and relationships of the affected elements, and then see whether the same can be achieved programatically.

 

Browsing a bit further, though, I see that you might very well run into a limitation; I searched for 'revit dimension style create a custom arrowhead type' and encountered this: 

 

https://knowledge.autodesk.com/support/revit-products/troubleshooting/caas/sfdcarticles/sfdcarticles...

 

Issue:

It is not possible to load a custom arrowhead when browsing to Manage > Additional Settings > Arrowheads
 

Solution:

Customize the existing Arrowhead System Family. 

An enhancement request in order to load custom families into the Arrowhead options has been logged on Revit Ideas. To see it and vote it up, see: Custom leader arrowhead

See Also:

 

So, I guess it depends a bit on exactly what you wish to achieve.

  

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 5

will.wydock
Advocate
Advocate

Hi Jeremy,

 

I did do the research however what I did find was not updating how I was expecting. I was not looking for a new symbol head for the leader arrow but a new arrowhead type with set parameters that could then apply to my dimensions. A quick standard fix as we reuse older models.

 

This is what I have created so far and I am still stuck at the creating arrowhead portion.

 

public void NewArrowhead()
		{
			string TickMarkName = "DimTick-Standard";
			Document doc = this.ActiveUIDocument.Document;
		    var provider = new ParameterValueProvider(new ElementId(BuiltInParameter.ALL_MODEL_FAMILY_NAME));
            var collector = new FilteredElementCollector(doc).OfClass(typeof(ElementType)).WherePasses(new ElementParameterFilter(new FilterStringRule(provider, new FilterStringEquals(), "Arrowhead", false)));
            var elements = collector.ToElements().Cast<ElementType>().ToList();
            ElementType newArrow;
            newArrow = elements.FirstOrDefault(x => x.Name.Equals(TickMarkName));
			var dimtypes = new FilteredElementCollector( doc ).OfClass( typeof( DimensionType ) );
            using(Transaction transaction = new Transaction(doc,"dude"))
            {
            	try
            	{
	            	transaction.Start();
		            if (newArrow == null)
		            {
		                var arrowDefault = elements.FirstOrDefault(x => x.Name.StartsWith("Arrow"));
		                if (arrowDefault != null)
		                {
		                    newArrow = arrowDefault.Duplicate(TickMarkName);
		                    
		                   
							newArrow.LookupParameter("Arrow Style").Set("Diagonal");
		               		newArrow.LookupParameter("Tick Size").Set(.09375);
		                }
		            }
					else
					{
		                newArrow.LookupParameter("Arrow Style").Set("Diagonal");
		               newArrow.LookupParameter("Tick Size").Set(.09375);
					}
					foreach (var x in dimtypes)
					{
						x.get_Parameter(BuiltInParameter.TEXT_FONT).Set("Arial Narrow");
						x.get_Parameter(BuiltInParameter.TEXT_WIDTH_SCALE).Set(1);
						x.get_Parameter(BuiltInParameter.DIM_LEADER_ARROWHEAD).Set(TickMarkName);
					}
					transaction.Commit();
            	}
					catch(Exception x)
					{
						System.Windows.Forms.MessageBox.Show(x.ToString());
					}
            }
		}
0 Likes
Message 4 of 5

emma_hundsdorferS6VHG
Observer
Observer

Was this ever resolved? I am searching for something similar, trying to make the Heavy Line "Tick size" to be instance based.

0 Likes
Message 5 of 5

jeremy_tammik
Alumni
Alumni

At least it seems t be possible to determine the arrowhead types, according to this discussion on how to delete them:

  

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes