Author Topic: Adjusting Fab Duct Fittings Ends Extension allowed in Revit  (Read 2212 times)

0 Members and 1 Guest are viewing this topic.

Offline bdelallanaTopic starter

  • Active Member
  • **
  • Posts: 5
  • Country: us
  • Gender: Male
When using Fabrication parts in Revit, the ductwork elbows & transitions are allowed to be stretch as far as anybody wants to. In AutoCAD Fabrication there is a setting where you can identify the maximum stretch lengths. Once the fitting has reached this limit it automatically starts adding duct straight lengths. Unfortunately, these settings in AutoCAD do not have any affect inside of Revit. I started to play around with dynamo to try to come up with a script in which it will fix the lengths of these fittings by a maximum allowed length. I was able to identify the fitting type by CID filtering. Then I make use of the "GetParamaterValuyByName" to get the "Bottom Extension" string which is the one that controls the lengths of one side of the Fitting. This provides me with the length of the fitting. I then make a Less than or equal to string that identifies if the "Bottom Extension" is less than or equal to 18". This Return a False or True Statement. Then I make use of the "If" string by telling it that if true, to keep the length reported from the "Bottom Extension" field. If the value return false then the length reported changes to 18". The problem I'm having is being able to write this information back to the fabrication parts. I attempted to make use of "SetDimesnionValue" taken from the Fabrication API dynamo package. This string only grabs one of the numbers in the list of the "If" string and applies it to all fittings "Bottom Extension". Can anybody take a look at this and see if there is any way to make this work and be able to apply the numbers obtained from the "If" string to the associated fabrication part? I have attached the dynamo code and an image that shows the graph for this code. How is everyone else dealing with the ductwork fittings stretching in Revit?
« Last Edit: Mar 30, 2021, 11:52:04 AM by bdelallana »

Offline Axl

  • Full Member
  • ***
  • Posts: 93
  • Country: us
  • Gender: Male
Re: Adjusting Fab Duct Fittings Ends Extension allowed in Revit
« Reply #1 on: Mar 30, 2021, 13:19:53 PM »
I work with Pipework, but I do the same and works fine, usually this issue is related to the list that feeds the "SetParameter" maybe needs to be flatten, or the number of values doesn't match the list of items.

First make sure the lists match at all levels, for instance a list with @L1, @L2 only won't match a list with @L1,@L2,@L3 even if they have the same number of element and they "look" in the same order, the "SetParameter" will read only only level and that can cause the issue.

* Use Levels
* Count the lists (match the counting)
* Flatten lists
* Use Watch nodes to see what is going on (and spot the list discrepancy)

Are you able to post the actual graph ?

nvm I just got the Dyn file, I'll give it a try

Follow Up:
Checking the graph, it seems like the node "SetDimensionValue" is intended to be used with a single value,

*******
if Cnt > 1:
   for e in Inpt:
      ItmDims = e.GetDimensions()
      f.append(e.SetDimensionValue(ItmDims[DimName], DimValue))
*******

And you need to be able to add one value per item, I changed it just a bit, in order to get the next value each time (not very elegant, but I played safe, because I cannot test it (I have no Duct):

******
if Cnt > 1:
   for e in Inpt:
      ItmDims = e.GetDimensions()
      f.append(e.SetDimensionValue(ItmDims[DimName], DimValue(index1)))
      index1 = index1 + 1
******

So in brief:

Create a new "Python Script" node, press the plus sign twice so you have the same amount of inputs as the original node, and connect the lines in the same order,

IN[0] << Fabrication Parts
IN[1] << DimIndex
IN[2] << Dim Value

double click to open it delete all inside and once is clean paste the following code don't include the line of **** at the beginning and at the end:

***STAR***(after this line)

import clr
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import FabricationPart
from Autodesk.Revit.DB import FabricationDimensionDefinition

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

Inpt = UnwrapElement(IN[0])
Cnt = UnwrapElement(IN[1])
DimName = UnwrapElement(IN[2])
DimValue = UnwrapElement(IN[3])
f = list()

Doc = DocumentManager.Instance.CurrentDBDocument
TransactionManager.Instance.EnsureInTransaction(Doc)
index1 = 0

if Cnt > 1:
   for e in Inpt:
      ItmDims = e.GetDimensions()
      f.append(e.SetDimensionValue(ItmDims[DimName], DimValue(index1)))
      index1 = index1 + 1
else:
   ItmDims = Inpt[0].GetDimensions()
   f.append(Inpt[0].SetDimensionValue(ItmDims[DimName], DimValue))

TransactionManager.Instance.TransactionTaskDone()

OUT = f#Inpt, DimName, DimValue, ItmDims

***END***(before this line)

It is possible that instead of "DimValue(index1)"  you need to use "DimeValue[index1]" but let's test it as it is first and let me know.
« Last Edit: Mar 30, 2021, 13:57:34 PM by Axl »
CADmep DB Manager
Content Manager
Scripting

Offline bdelallanaTopic starter

  • Active Member
  • **
  • Posts: 5
  • Country: us
  • Gender: Male
Re: Adjusting Fab Duct Fittings Ends Extension allowed in Revit
« Reply #2 on: Mar 30, 2021, 13:26:59 PM »
Yes, the picture of the graph and the DYN file was posted.

I'm going to try to flatten the list and see if that does anything.

when using the DYN remember that it works based off the CID number of the fab part.

Offline bdelallanaTopic starter

  • Active Member
  • **
  • Posts: 5
  • Country: us
  • Gender: Male
Re: Adjusting Fab Duct Fittings Ends Extension allowed in Revit
« Reply #3 on: Mar 30, 2021, 15:28:40 PM »
So in brief:

Create a new "Python Script" node, press the plus sign twice so you have the same amount of inputs as the original node, and connect the lines in the same order,

IN[0] << Fabrication Parts
IN[1] << DimIndex
IN[2] << Dim Value

double click to open it delete all inside and once is clean paste the following code don't include the line of **** at the beginning and at the end:

This would be a good approach. However, given that the amount of fitting will be a variable (depending on how many duct fittings are in your project) it would be impossible to match the inputs in order since there is no set amount of inputs that will be needed.

Offline Axl

  • Full Member
  • ***
  • Posts: 93
  • Country: us
  • Gender: Male
Re: Adjusting Fab Duct Fittings Ends Extension allowed in Revit
« Reply #4 on: Mar 30, 2021, 16:16:14 PM »
The number of fittings is not relevant, it can be 1 or 1000, the script still should work as it loops until all fittings are done.

the line:

"for e in Inpt:"

means, repeat this until the list is exhausted no matter how many.
CADmep DB Manager
Content Manager
Scripting

Offline bdelallanaTopic starter

  • Active Member
  • **
  • Posts: 5
  • Country: us
  • Gender: Male
Re: Adjusting Fab Duct Fittings Ends Extension allowed in Revit
« Reply #5 on: Mar 30, 2021, 16:49:48 PM »
Awesome! I'm not good at coding at all, I'm new to this. Let me give this a try and I will let you know how it goes!

Offline bdelallanaTopic starter

  • Active Member
  • **
  • Posts: 5
  • Country: us
  • Gender: Male
Re: Adjusting Fab Duct Fittings Ends Extension allowed in Revit
« Reply #6 on: Mar 30, 2021, 17:14:50 PM »
I created the Python Script and deleted everything inside. I pasted the code you wrote and ran it but it gave me an error on line 20. See attached image. What is the message trying to say regarding the code?

Offline Axl

  • Full Member
  • ***
  • Posts: 93
  • Country: us
  • Gender: Male
Re: Adjusting Fab Duct Fittings Ends Extension allowed in Revit
« Reply #7 on: Mar 30, 2021, 21:03:59 PM »
first thing I see. Flatten the list chop and try again, remember the lists should all look the same, as you can see in yours, you have one individual list per item, we need a clean list of all values together.
CADmep DB Manager
Content Manager
Scripting