Dimension from line or points of wall

hey, how is it possible to create dimension for plan from the wall lines or wall start and end points that we extract from model?

here is the script that procced up to this step

walls = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls).WhereElementIsNotElementType().ToElements()

wallLocations = [wall.Location for wall in walls]

wallCurves = [wallLoc.Curve for wallLoc in wallLocations]

lenght_wall=[i.Length for i in wallCurves]

wall_line=[i for i in wallCurves]
startpoint=[i.GetEndParameter(0) for i in wallCurves]

endpoint=[i.GetEndParameter(1) for i in wallCurves]

thanks in advance

You will find two methods here ApiDocs.co

They have examples in cs but it is pretty readable even if you don’t code in CS.

I tried to use this method NewDimension Method (View, Line, ReferenceArray)
but when I add the related class for NewDimenstion to my script, I faced with this error.

Exception : IronPython.Runtime.Exceptions.ImportException: Cannot import name ItemFactoryBase

so how can I use this method?

please post your code and format it accordingly selecting your code and then pressing image in the toolbar

The question you have now is regarding a failed import in the very first few lines of your code.

from Autodesk.Revit.DB import FilteredElementCollector, BuiltInCategory,ItemFactoryBase

walls = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls).WhereElementIsNotElementType().ToElements()

wallLocations = [wall.Location for wall in walls]

wallCurves = [wallLoc.Curve for wallLoc in wallLocations]
    

lenght_wall=[i.Length for i in wallCurves]

wall_line=[i for i in wallCurves]

startpoint=[i.GetEndParameter(0) for i in wallCurves]

endpoint=[i.GetEndParameter(1) for i in wallCurves]

for i in wall_line:    
  ItemFactoryBase.NewDimension()

you need to use NewDimension Class from the Document.Create in the Revit.Creation Namespace of the revit API

check this working example

I did it some changes according to your script and advice but I faced with this error

Exception : Microsoft.Scripting.ArgumentTypeException: NewDimension() takes at least 4 arguments (3 given)

while NewDimension give 3 argument

from Autodesk.Revit.DB import FilteredElementCollector, BuiltInCategory,Dimension

from Autodesk.Revit.Creation import Document

walls = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls).WhereElementIsNotElementType().ToElements()

wallLocations = [wall.Location for wall in walls]

wallCurves = [wallLoc.Curve for wallLoc in wallLocations]
    
wall_line=[i for i in wallCurves]

ra=ReferenceArray()

for i in wallCurves:
  ra.Append(i.GetEndPointReference(0))
  
  ra.Append(i.GetEndPointReference(1))

            
Document.NewDimension(doc.ActiveView,wall_line,ra)
   

Please have a look again at the latest link, the example from Cyril’s code repository