Example Conversion Parameter Parameter type secondary development of a Group revit

1 Background
junior partner in doing revit secondary development, you may need to convert each instance of the type parameters and parameter family in the family environment.

2 ideas
1. Group Manager FamilyManager, see note 1
2 first acquires the parameters to be converted (single and batch), see Note 3
3. Examples Parameter Parameter type transfer, transfer type parameter or parameters instances turn examples, see Notes 4,5

3代码
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;

heiyedeqishi namespace
{
[the Transaction (TransactionMode.Manual)]
class Revit_API_Executable1: IExternalCommand
{
public the Execute the Result (ExternalCommandData commandData, REF Message String, ElementSet Elements)
{
UIDocument uidoc = commandData.Application.ActiveUIDocument;
the Document DOC = uidoc.Document;
the try
{
the Transaction trans = new Transaction (doc, "conversion parameter");
trans.Start ();
// get. 1 familyManager
familyManager familyManager = doc.FamilyManager;
// group 2 obtained by the parameter name
FamilyParameter singleParameter = familyManager.get_Parameter ( "material") ;
// group 3 obtained by traversing parameters
foreach (familyParameter familyParameter in familyManager.Parameters)
{
// type conversion Example 4
familyManager.MakeInstance (familyParameter);
// turn type. 5 Example
familyManager.MakeType (familyParameter);
}
trans.Commit ();
return Result.Succeeded;
}
the catch (Exception EX)
{
Message = EX. the Message;
return Result.Failed;
}
}
}
}

. 1
2
. 3
. 4
. 5
. 6
. 7
. 8
. 9
10
. 11
12 is
13 is
14
15
16
. 17
18 is
. 19
20 is
21 is
22 is
23 is
24
25
26 is
27
28
29
30
31 is
32
33 is
34 is
35
36
37 [
38 is
39
40
41 is
42 is
43 is
44 is
45
46 is
47
48
4 Note matters
1. If this parameter is itself an instance parameter, even then converted instance parameters also, not being given
type parameter, ibid.
2. Because of their own in the family environment, the need to open a document family, if the family need to open the document specified by the program, see bloggers another article batch of secondary development of open revit family documents, template files, project files
- -------------------- 

Guess you like

Origin www.cnblogs.com/ly570/p/10935456.html