Message 1 of 5
How to Create Arrow Types?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I want to create a new Arrow Type "22 Degree Filled Arrow" and "22 Degree Filled Arrow"
Arrow Style: Arrow
Fill Tick: = ON
Arrow Closed : OFF
Arrow Width Factor = 22deg
Tick Size = 3/32"
I'm looking for a sample or tutoiral that can be used to create new arrow types using the duplicate type.
I'm using the Built In Parameter Checker to get Parameter Names which I can use to change the parameter values above.
For TextNotes I used:
ICollection<ElementId> textNotes
= collectorUsed.OfClass(typeof(TextNote))
.ToElementIds();
But I'm not sure what to replace "TextNote".
using System;
using System.Collections.Generic;
using System.Collections;
using System.Windows.Forms;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using System.Text;
using System.Linq;
namespace CreateTextType
{
/// <summary>
/// Revit Create Revit Arrow Head Style
/// Created by. Matt Fleming C.E.T.
///
/// KNOWN LIMITATIONS:
///
///
/// </summary>
/// <remarks></remarks>
///
[Transaction(TransactionMode.Manual)]
public class cmdArrowType : IExternalCommand
{
/// <summary>
/// Command Entry Point
/// </summary>
/// <param name="commandData">Input argument providing access to the Revit application and documents</param>
/// <param name="message">Return message to the user in case of error or cancel</param>
/// <param name="elements">Return argument to highlight elements on the graphics screen if Result is not Succeeded.</param>
/// <returns>Cancelled, Failed or Succeeded</returns>
public Result Execute(ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
try
{
// Action Code Starts Here
List<Element> ret = new List<Element>();
Document doc = commandData.Application.ActiveUIDocument.Document;
/// Retrieve access to all arrowType Elements
FilteredElementCollector collectorUsed
= new FilteredElementCollector(doc);
ICollection<ElementId> arrowTypes
= collectorUsed.OfClass(typeof(ArrowType))//ArrowType is Wrong
.ToElementIds();
foreach (ElementId arrowTypeId in arrowTypes)
{
ArrowType arrownote = doc.GetElement(//ArrowType is Wrong
arrowTypeid) as ArrowType;//ArrowType is Wrong
Transaction trans = new Transaction(doc);
trans.Start("CreateNewArrow");
// Create a duplicate
Element ele = arrownote.arrowType.Duplicate(newArrowType);
arrowTypeType arrowType = ele as arrowTypeType;//arrowTypeType is Wrong
// Change font parameter
if (null != arrowType)
{
// Arrow Filled 1 = ON 0 = OFF
arrowType.get_Parameter(BuiltInParameter.ARROW_FILLED).Set(1);
// Arrow Size Double
arrowType.get_Parameter(BuiltInParameter.ARROW_SIZE).Set(0.125);
// Arrow Type Integer
arrowType.get_Parameter(BuiltInParameter.ARROW_TYPE).Set(8);
// Arrow Leader Width Double Degrees
arrowType.get_Parameter(BuiltInParameter.ARROW_LEADER_ARROW_WIDTH).Set(22);
// Arrow Closed 1 = ON 0 = OFF
arrowType.get_Parameter(BuiltInParameter.ARROW_CLOSED).Set(0);
}
trans.Commit();
}
// Return Success
return Result.Succeeded;
}
catch (Exception ex)
{
// Failure Message
message = ex.Message;
return Result.Failed;
}
}
}
}
Matt
