Hi. Quick question:
How do i implement Category.ByName in a python script?
And is there a place where i can figure this out myself for the future?
Hi. Quick question:
I’m not sure if this is the one you’re after:
Is this what you want?
The call in the Python script is simply:
Thanks for the reply!
That last line is exactly what i want!
Do i simply import it in the following manner?
I hope you have the time to answer yet another question that is more or less related. I get an error when trying to implement referencepoint.bypointvectordistance.
I want to go from a list of initial points, along two vectors, so i end up with a set of new points
i have the following code:
import clr clr.AddReference('ProtoGeometry') from Autodesk.DesignScript.Geometry import * clr.AddReference("RevitNodes") import Revit x = IN initPoints = [(x[i].StartPoint) for i in range(len(x))] newPoint= for i in range(len(b)): y=Revit.Elements.ReferencePoint.ByPointVectorDistance(initPoints[i],x[i].Direction,x[i].Length/2) c=Revit.Elements.ReferencePoint.ByPointVectorDistance(y,x[i].Direction,x[i].Length/2) newPoint.append(c) OUT = newPoint
This should be changed to “x = IN”
You are not defining “b” anywhere this causes your error. There might be other issues I have not found by a glance.
To the last matter you would “initialize” like so:
import clr clr.AddReference('RevitNodes') import Revit OUT = Revit.Elements.Category.ByName(IN)
Lastly be careful about using the subscripts such as x to go through your lists as this make them very prone to errors if your level of lists change…
If you want to use core Dynamo nodes in Python you need to import them.
clr.AddReference('DSCoreNodes') from DSCore import *
Thanks again for the reply! I think my problem is that i don’t understand how the referencepoint.bypointvectordistance works. I have added a screenshot of how i think it works, hope you will spot the mistake, the error message is: “Element cannot be created in current context”
Your original question was already answered. For your second query you should mark one of the above answer as solution and start a new thread
However the error says you can’t create Reference point in Project environment, you should use this node in family environment. Does that makes Sense?
Why are you using python code for almost all your operations? Why not stay in OOTB nodes?
Curious if there is a reason for this?
I guess there is a couple of reasons, though i don’t know if its justified:
Most of what i do must be scalable, a lot of loops and list operations. I also don’t know any designscript yet, while I know some python. Hopefully i will learn more as i go.
An additional bonus with using python is that I use it a lot studying mechanical engineering and I need all the excercise I can get
takker så meget for all hjelpen
Det var så lidt
I understand your reasons though you might find that this forum is more keen on resolving issues, that is not directly in need of “loops”, with nodes as this is the most “dynamo-y” way.
Even using nodes you will be able to make large scale-able solutions you just need to understand lacing and list-levels. This will man times make better solutions than you coding everything up in small individual python nodes
Even then you do not need any DesignScript knowledge, most can be solved using simple nodes with correct lacing and list-levels. And then finally if any “for-, if- or while-loops” are needed you can start using Python. Much of the time Dynamo is actually better at handling lists than Python will be, unless of course you’re using certain algorithm to traverse your data in Python though I doubt with the limitations of IronPython though
Though I as a student of Architectural Engineering understand your reasons for wanting to learn Python coding on the fly