How to create railing by CurveLoop

Hi, friends!!
I want create railing by CurveLoop. I using this create method from revit API:
But in OUT I have a null. Why? there are no warnings. What have I done wrong?

But in OUT I have a null. Why? there are no warnings. What have I done wrong?

This is Python code:

This is all script:

Did you solve the problem ? I get it the same.

You need to ensure the curve set have coincident start/end points and the start point of curve A meets the end point of curve B. If the start points of two curves are coincident, the curve loop with fail, so you may need to write some additional python code to evaluate the junction conditions and reverse one of the curves if that is the case.

3 Likes

Very thanks for your replay!!!

I tried just apending a line type in a curveloop data(such as a line type data from [0,0,0] to [1000,0,0],was appended to the curveloop by the method append),also comes the error:the sketch is null.
In my thoughts,I think , if just one line type data append to the curveloop comes errors, it has some other error in the way I use the api?

Could you give some example codes? or,some example points data?

1 Like

I have not solved this problem yet. I will be grateful for the help.

I use the revit api by C#.
I meet the problem you have got.
Also,I found that,if I open a file by hand,and use the document like:
Autodesk.Revit.DB.Document revit = commandData.Application.ActiveUIDocument.Document;

It is ok when I use the revit api.Just if the points is right.

But,if I do like this:
Autodesk.Revit.DB.Document revitdoc = commandData.Application.Application.NewProjectTemplateDocument(@“C:\ProgramData\Autodesk\RVT 2017\Templates\China\DefaultCHSCHS.rte”);

I create a new file by codes, the error will come ,“the sketch is null”.

Hey. Don’t know why your’s is not working, but this one is working for me:

doc = DocumentManager.Instance.CurrentDBDocument
railType = UnwrapElement(IN[0])
curves = IN[1]
level = UnwrapElement(IN[2])

TransactionManager.Instance.EnsureInTransaction(doc)
revitCurves=[]
for curve in curves:
	revitCurves.append(curve.ToRevitType())

curveloop = CurveLoop.Create(revitCurves)

Autodesk.Revit.DB.Architecture.Railing.Create(doc,curveloop, railType.Id,level.Id)

TransactionManager.Instance.TransactionTaskDone()

Finally,I get the information:
If I create a document by api,the codes is not well.
But if I create a document by UI click,the codes will work.
Thanks very much!Have a nice day.

please tell us in more detail. I do not quite understand

really! My code also works))) I’m an idiot … I do not know why he did not work before. thanks for the help!

hello,

your code didn’t work for me :frowning: i got this warning : no module named transactions

Hey,

Have a look at the first post, you need to import all the modules… Everything from ‘import clr’ downwards… Transactions comes from the RevitServices module as does DocumentManager…

There is good advice on learning Python with Dynamo here…

Hope that helps,

Mark

2 Likes