Snooping and calling of BuildInParameters?

Hello,

Learning:

import System
import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

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

wall = UnwrapElement(IN[0])

bottomext = wall.get_Parameter(BuiltInParameter.WALL_BOTTOM_EXTENSION_DIST_PARAM).AsDouble()
topext = wall.get_Parameter(BuiltInParameter.WALL_TOP_EXTENSION_DIST_PARAM).AsDouble()  

OUT = bottomext,topext

So i try to get Parameters(BuildIn) from my wall. Top/Basement Offset, it shows 0. in my testfile the wall has an offset.

How can snoop my BuildinParameters which Object Type they have f.e. is length, area and volums are all Double ? how do i navigate with the lookupTable? (in my example)


So have i to give “digits” ?

BuiltInParameter is WALL_BASE_OFFSET and WALL_TOP_OFFSET I believe.

Also when you snoop, you can go into Parameter Set like you show, then there is a button I believe on the bottom left that says Enums something. This will give you the BIP associated.

1 Like

@SeanP ,

do you know how to get to the metric system ?

offset it seems to it is in inches and foot


is there somthing like doubleAsMeters ?

KR

Andreas

There is a node called “Convert Between Units” :wink:

do you know how to get to the metric system ?

@leonard.moelders i know but i got an error!

import System
import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

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

wall = UnwrapElement(IN[0])

bottomext = UnitUtils.ConvertFromInternalUnits(wall.get_Parameter((BuiltInParameter.WALL_TOP_OFFSET).AsDouble(), DisplayUnitType.DUT_MILLIMETERS)
topext = UnitUtils.ConvertFromInternalUnits(wall.get_Parameter(BuiltInParameter.WALL_BASE_OFFSET).AsDouble(), DisplayUnitType.DUT_MILLIMETERS)

OUT = bottomext,topext

you mean literal ConvertBetweenUnits i use ConvertFromInternalUnits but i got an syntex error
i started a new topic already
2022-05-20_08h51_48

Do you need to do it in python? With the node it should work:

no, but i learn. I want useing the Revit API as enviroment. @leonard.moelders

Then try this:

you need to watch out for your revit version, it seems you’ve looked into an api-documentation for an older version as in Revit >=2022 there was a change.

To adress this problem you can use something like this to get your code working for older and newer versions of revit:

if int(DocumentManager.Instance.CurrentUIApplication.Application.VersionNumber) < 2021:
				factor = UnitUtils.ConvertToInternalUnits(304.8,doc.GetUnits().GetFormatOptions(UnitType.UT_Length).DisplayUnits)
			else:
				factor = UnitUtils.ConvertToInternalUnits(304.8,doc.GetUnits().GetFormatOptions(SpecTypeId.Length).GetUnitTypeId())
1 Like
wall = UnwrapElement(IN[0])

bottomext = wall.get_Parameter(BuiltInParameter.WALL_BASE_OFFSET).AsDouble()
convbott = UnitUtils.Convert(bottomext,UnitTypeId.Feet,UnitTypeId.Millimeters)

topext = wall.get_Parameter(BuiltInParameter.WALL_TOP_OFFSET).AsDouble()  
convtop = UnitUtils.Convert(topext,UnitTypeId.Feet,UnitTypeId.Millimeters)

OUT = convbott, convtop

it works but i create 2 variables… @leonard.moelders is there a way to do it in one line?

what do you want in one line exactly?

just getting the offsets in my project units … later on i will do some QM issues

so walls have no offset , floors a.s.o. @leonard.moelders I want to learn navigate in the API inviroment.

You get your top und bottom offset as you want. So what is the problem here? Which part of your code do you want to be an one-liner?

is there a way to comprehense the code. So to store the unitsconverting and the value in the same variable?

if it not is ok for me @leonard.moelders

You could use a def:

wall = UnwrapElement(IN[0])

def UnitConverter(builtinparameteroffset, fromunit, tounit):
	text = wall.get_Parameter(builtinparameteroffset).AsDouble()
	conv = UnitUtils.Convert(text,fromunit,tounit)
	return conv

builtinparameteroffset_list = [BuiltInParameter.WALL_BASE_OFFSET, BuiltInParameter.WALL_TOP_OFFSET]

fromunit = UnitTypeId.Feet

tounit = UnitTypeId.Millimeters

output = []

for item in builtinparameteroffset_list:
	output.append(UnitConverter(item, fromunit, tounit))

OUT = output

But this is only shorter, if you do it several times

Or simply save some lines like this:

wall = UnwrapElement(IN[0])

convbott = UnitUtils.Convert(wall.get_Parameter(BuiltInParameter.WALL_BASE_OFFSET).AsDouble(),UnitTypeId.Feet,UnitTypeId.Millimeters)

convtop = UnitUtils.Convert(wall.get_Parameter(BuiltInParameter.WALL_TOP_OFFSET).AsDouble(),UnitTypeId.Feet,UnitTypeId.Millimeters)

OUT = convbott, convtop
1 Like

@leonard.moelders yes, i got from @Elie.Trad the same conclution! Many thanks … :slight_smile:

1 Like

And if you ever have problems with the api:

Use this page: ApiDocs.co

There you can find examples for that use what you are looking for, e.g. for your case:

2 Likes