- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,i want to create a sweep in a temporary family document and load the family document in a opened project document, i have two problems:
1、i want to create a new family document programmatically,first i need to find a template,but i always fail,the code is
ExternalCommandData commandData;
Application app = commandData.Application.Application;
string familyTemPath = System.IO.Path.Combine(app.FamilyTemplatePath, "公制结构框架 - 综合体和桁架");
the familyTemPath always shows "\Templates\公制结构框架 - 综合体和桁架", it is not the correct family template path,it means “app.FamilyTemplatePath” doesn't work, i can not find the correct template path;
2、I can't retrieve paths, I can only write the path myself,but when i load the family document with a sweep,the project document has nothing,the code is
ExternalCommandData commandData;
Application app = commandData.Application.Application;
Document doc = commandData.Application.ActiveUIDocument.Document;
string famTempl = @"C:\ProgramData\Autodesk\RVT 2016\Family Templates\Chinese\11公制结构 框架 - 综合体和桁架.rft";
Document familyDoc = app.NewFamilyDocument(famTempl);//the document can be created successfully
Transaction transaction = new Transaction(familyDoc, "create a sweep");
transaction.Start();
Sweep wall = CreateSweep(familyDoc, sweepProfile);//This is a piece of encapsulated code for creating sweep. I tested it can create a sweep successfully.
Family family = familyDoc.LoadFamily(doc);
transaction.Commit();
familyDoc.Close(false);
There was no sweep in the project document after the code was run,and there was no mistake.i don't know where the problem is.
i need your help,thank you.
Solved! Go to Solution.