FamilyInstance.ByPoint overwrites

Hi @DaveP

Use Dynamo Player.

1 Like

I need to have input - Select an Element for the Path - so I can’t run it automatically

Also, just found this thread

But their “Close and re-open” solution didn’t work for me

Use “Pick Model Elements” Custom node from Rhythm package to select elements in each run. Hope that makes sense!

Thanks for the quick responses
Found another thread the has a link to GitHub. (Which you were an active participant on ! )

It says that this is “working as intended” for that node.

I’ll try the Rhythm node / Player trick after lunch

I am actually going through this same thing now. Does my node really allow this? :laughing:

@john_pierson Yep!

1 Like

rewrite code from the first post.

I posted whole this code somewhere else in aanother post, but cannot find it.
Basically you need to open & close transaction for every change, that’s why it’s inside ‘for’ loop. Or mby I’m totally wrong, but at least it works this way :smiley: Marking solution for dynamo player is kinda wrong, cause u won’t run dynamo player in revit 14/15/16

I’m going to have to re-work a few things.
I’ve got two inputs in my original - one to pick the family and another to pick the path.
First time I tried to run it with Player, it just spun away & I had to use Task Manager to kill it.
So I’ll have to either give up on selecting the family, or pipe that in some other way.

Running through this problem my self.
My solution is:

  1. Run in Dynamo

  2. Cut/Paste in place elements in Revit

  3. Run again in Dynamo


Thanks, John.
Perhaps you know why I have to bother with this, though. I asked over here

about why the FamilyInstance.ByPoint node bonds itself to the Instances & haven’t gotten an answer.
I’m sure there’s some logic but I can’t think of why you would want to always use the same Family for every subsequent run.

@DaveP @john_pierson I got this bad boy fixed :slight_smile:

Here is the code:

import clr

import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc =  DocumentManager.Instance.CurrentDBDocument

import Revit

from Autodesk.Revit.DB import *

def ptslist(obj1):
	if hasattr(obj1,"__iter__"): return obj1
	else: return [obj1]

famType = UnwrapElement(IN[0])
pts = ptslist(IN[1])
lvl = UnwrapElement(IN[2])

elems = []

for pt in pts:
	elems.append(doc.Create.NewFamilyInstance(pt.ToRevitType(True), famType, lvl, Structure.StructuralType.NonStructural))
OUT = elems

Works great! Thank you sir.

However, might I be so bold as to make one more request? (I know, I’m greedy)
Can you do the same thing for FamilyInstance.SetRotation?
Apparently, all of the FamilyInstance nodes bind to the initial element, so I had to Freeze that node in my graph.

This is fantastic! Ditto @DaveP question on FamilyInstance.SetRotation. Is this something that has been picked up in the past few weeks?

I’ve been struggling with the similar problem for a bit, and here’s what I came up with:

  1. Using the ‘Family Instance By Point in Transaction’ node from the Bakery package (authored by @Luke_Johnson), solves the problem with disappearing elements each time you run the graph;

  2. Then I modified this custom node to add an activation for the family symbol:
    # Make sure the familysymbol is active if famtype.IsActive == False: famtype.Activate() doc.Regenerate()
    This ensures that your family, that you have just loaded to the project, will be ‘recognized’ by Revit.

  3. Placed the ‘FamilyInstance.SetRotation’ at the end of the graph, so that Dynamo firstly places my family instances, and then rotates them.

  4. So each time I run the graph, it places new instances of chairs and rotates them:

And here are the caveats:

  1. Using ‘FamilyInstance.SetRotation’ becomes tricky when you need to place families by curve (dynamo ‘curve’ == revit ‘line’). This is because each curve has its direction (oops :rage: ), and so does the tangent vector ('Curve.TangentAtParameter) at each point of this curve. And when you try to get rotation angle between tangent vector and i.e. YAxis, you’ll probably get some negative values;

  2. Of course, the way your family is built (in terms of directions inside the family editor) will also affect rotation. My graph is still work in progress, and I suppose that it won’t be universal as I previously planned;

  3. Instead of using lines, you can get the curves from in-place family by selecting one of its edges. But the problem is that these edges may be cut by walls or other intersecting elements.

How would this be modified for placing instances in the view, instead of a level? I’m having a hard time figuring out how to convert revit api notes into python code.

Best to start a new topic with the usual ‘this is where I am’ and ‘this is where I want to be’ content and link back here as this is a fairly significant departure and will likely be useful to others in the future.

Ok, I’ve done so here: Close transaction with each run of the script using place instance per view

1 Like

2 posts were split to a new topic: Replacing Family Instances with new Family