Revit API

Reply
Active Contributor
mfleming.stantec
Posts: 32
Registered: ‎10-06-2009
Message 1 of 2 (444 Views)

How to Create Arrow Types?

444 Views, 1 Replies
10-13-2012 06:39 PM

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

Employee
saikat
Posts: 185
Registered: ‎08-16-2007
Message 2 of 2 (402 Views)

Re: How to Create Arrow Types?

10-25-2012 01:43 PM in reply to: mfleming.stantec

Hi Matt

 

I would insert an instance of the arrow in the current Revit model and then use the Revit Lookup tool after selecting the instance and dig out the category, type, etc information and plug those in the code.

 

If you need further help with this, can you please specify which specific family can I use to create an instance of this in a Revit model. Or if you want to include the arrow family file as an attachment, I could take a further look if you need me to. Please do ensure that any of your attachments do not include any confidential information.

 

hope this helps.



Saikat Bhattacharya

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!