codeFreak24
codeFreak24

Reputation: 201

How to Duplicate current `Family Type` and update it's parameters

We are using Autodesk's Forge (or Platform Service), more specifically, the Design Automation where we run scripts on our files in the cloud.

We are looking into ways to import a "Type Catalog" (which is a ".txt" file) into the opened ".rfa" file using Design Automation. One possible way is to parse the .txt file and then Duplicate the current/opened Family Type and after that update the parameters in the Duplicated Family Type with values from the txt file and lastly set the CurrentFamilyType to the new Family Type.

Since we can only use "Autodesk.Revit.DB;" (No UI allowed), we couldn't figure out how to Duplicate the current Family Type and to achieve the aforementioned task. Normally, using the Revit app, we could just select Create -> Family Types -> New Type and create a new family type, or we could go Insert -> Import Family Types and then select the .txt file and import the new type, but as I said, without UI, that's not possible, so we have to work around this with the possible solution I mentioned earlier.

Any information or example on how we could achieve the result we want would be greatly appreciated!

*The .txt file is located inside the AppBundle with the rest of the files we use in Design Automation.

Upvotes: 3

Views: 522

Answers (2)

Rahul Bhobe
Rahul Bhobe

Reputation: 4451

Give this a try:

  1. Open the family document.
  2. Access Document.FamilyManager.
  3. Call FamilyManager.NewType().
  4. Change the FamilyManager.CurrentType.
  5. Parse and apply your text file.

I would try this locally before sending it to design automation. Learn how to Debug Revit plugin locally.

Upvotes: 2

Jeremy Tammik
Jeremy Tammik

Reputation: 8339

Please check out the closely related Revit API forum discussion on Importing Type Catalog .txt into .rfa at runtime. It includes sample code verified to work in both the .NET desktop and the APS Design Automation APIs.

Upvotes: 2

Related Questions