Quick one pls - calling custom node from Python script

Hi there,

I think this is a very simple one but have searched for quite a bit and cannot seem to find any mention of it online!

I am trying to call a Clockwork custom node (FamilyInstance.ByPointInView) from within a Python script node as I would like to loop it.

I thought it would be adding ‘import Clockwork’ or something like that - could some one help please?

Many thanks in advance.

Hello, I assume that you’ve already seen that:

Thanks - yes I have, though the responses were from 2 years ago so I was wondering if that is still the case now?

I would suggest to address this question to someone proficient by using an @ address (I suppose that a personal message would be sent but I admit that never tried it myself)…

Nothing’s changed

1 Like

while the answer to your question is no (“can I call a custom node”),
the goal you are trying to achieve is possible (“as I would like to loop it”).

Obviously, you can loop over it by feeding a list of points, but if you need to customize it (ie use different types as inputs, you can just use the code from the custom node, which is quite simple, as a function in your python code.
Example below (not tested)

fam_instance_by_point(point, famtype, lvl):
    # From FamilyInstance.ByPointInView.dyf at
    # github.com/andydandy74/ClockworkForDynamo/            
    # make sure familysymbol is active
    if famtype.IsActive == False:
    newobj = doc.Create.NewFamilyInstance(point.ToXyz(),famtype,lvl)
    return newobj.ToDSType(False)

created_instances = []
for point in points:
    element_instance = fam_instance_by_point(point, famtype, lvl)

Thanks everyone. Thanks Gui I will look at doing that.