Edit Family

Edit Family

sobon.konrad
Advocate Advocate
2,308 Views
10 Replies
Message 1 of 11

Edit Family

sobon.konrad
Advocate
Advocate

Is there a way to Edit Family, but NOT via the doc.EditFamily() call because that doesn't open the UI family editor. I want to pull up a family editor in all its glory. So the next thing that came to my mind was to try the app.OpenAndActivateDocument() but that cannot be called from an event handler and unfortunately I am making this call from an IdlingEvent handler. I know what a bummer! Ok, next is something dirty that I have been thinking. What if I added a family instance to selection app.ActiveUIDocument.Selection.SetElementIds() and then posted the Edit Family command? Well, that fails silently and i get nowhere. Any more ideas? Is there perhaps a jurnaling method that i can adopt here? 

0 Likes
Accepted solutions (1)
2,309 Views
10 Replies
Replies (10)
Message 2 of 11

aignatovich
Advisor
Advisor

Hi!

 

You can try to use External events and .Net Process.Start

Message 3 of 11

sobon.konrad
Advocate
Advocate

You mean Process.Start(revit.exe, jurnalFilePath)? That is not exactly going to work here since it would open the family for editing in a different Revit session all together. Right? 

0 Likes
Message 4 of 11

aignatovich
Advisor
Advisor
Accepted solution

Process.Start("path to rfa")

There are some problems with this approach: first of all, if there are 2 or more instances of Revit.exe, it is not determined, where family will be open, secondly, 2 or more different Revit versions could be installed.

 

I recommend to try external events approach, not only for this task, but to replace Idling event processing.

 

I almost sure, it will work, I developed modal-less form with family catalogue and raise external events to load family to the documents.

 

Take a look at Revit SDK 2017\Software Development Kit\Samples\ModelessDialog sample from SDK

Message 5 of 11

sobon.konrad
Advocate
Advocate

Yes sir! You are indeed correct. ExternalEvent is the only way to handle this. Somehow when inside of an Idling Event one cannot use the OpenAndActivateDocument() method, but it works just fine from an External Event Handler. Thanks for the suggestion! 

0 Likes
Message 6 of 11

Anonymous
Not applicable

Where is the Process method located? I'm trying to edit a family through the Revit API, but I don't know where I can even start.

Here's a screenshot of the rfa opened with Revitfamily.jpg

Thanks a lot

0 Likes
Message 7 of 11

aignatovich
Advisor
Advisor

Hi!

 

Process is a .Net framework class. It is in a System.Diagnostics namespace

Message 8 of 11

Anonymous
Not applicable

So, with the Process method, how can I edit the family parameters?

0 Likes
Message 9 of 11

Anonymous
Not applicable

Or with EditFamily instead, I need to edit the parameters of the rfa.

0 Likes
Message 10 of 11

aignatovich
Advisor
Advisor

If you need to perform some editions to family you should use Application.OpenDocumentFile (String), it will return Document object.

 

Or if your Family is in project use Document.EditFamily method. It also returns the Document object.

 

Your code should be something like this:

 

var famDoc = app.OpenDocumentFile(path); // or doc.EditFamily(family)

using(var transaction = new Transaction(famDoc, "do something"))
{
transaction.Start();

// perform your logic

transaction.Commit();
}

// load edited family to the document or just save family

famDoc.Close(false);
Message 11 of 11

paulo.belesa
Contributor
Contributor

So I created a test  family called CUBE,  and yes its a simple cube. 
I want to create an html  form or UI screem  , where you can enter the 3 main values L , "width length and height" and 2 button , Execute and Reset . 
So once the execute button is pressed , the cube is changed. 

Is it possible to be done? 

 

Thanks 

0 Likes