NewLinearDimension input not met

NewLinearDimension input not met

crapai
Advocate Advocate
409 Views
6 Replies
Message 1 of 7

NewLinearDimension input not met

crapai
Advocate
Advocate

I'm trying to create a dimension between a reference line and plane and I'm getting and error saying input are not satisfied. It looks like from the API that I am meeting everything. What am I doing wrong?

 

 

Here is the error on line 36 below:

Exception: One of the conditions for the inputs was not satisfied. Consult the documentation for requirements for each argument.

 

t = Transaction(doc, "pyRevit - Create Reference Plane")
famMan = doc.FamilyManager


t.Start()
# Parameters
# Label __ Left Right
famMan.AddParameter("Label __ Left Right", GroupTypeId.Constraints, SpecTypeId.Length, True)
# Label __ Off Wall
famMan.AddParameter("Label __ Off Wall", GroupTypeId.Constraints, SpecTypeId.Length, True)
# Label_Dim_LeftCorrection
famMan.AddParameter("Label_Dim_LeftCorrection", ForgeTypeId(), SpecTypeId.Length, True)
# Label_Dim_OffsetFromWallCorrection
famMan.AddParameter("Label_Dim_OffsetFromWallCorrection", ForgeTypeId(), SpecTypeId.Length, True)


p = Plane.CreateByNormalAndOrigin(XYZ.BasisZ, XYZ(0, 0, 0))
sp = SketchPlane.Create(doc, p)

# Ref Plane Label Anchor
refSymbolAnchorLeft = doc.FamilyCreate.NewReferencePlane(XYZ(-3,-1,0),XYZ(-3,1,0), XYZ(0,0,1), cView)
refSymbolAnchorLeft.Name = "Symbol Anchor"
refSymbolAnchorLeft.Pinned = True
refSymbolAnchorLeft.LookupParameter("Is Reference").Set(12)

# Ref Line Label Vertical Center
lsvc = Line.CreateBound(XYZ(2, -2, 0), XYZ(2, -4, 0))
lineSymbolVerticalCenter = doc.FamilyCreate.NewModelCurve(lsvc, sp)
lineSymbolVerticalCenter.ChangeToReferenceLine()

# Create Dimension
ra = ReferenceArray()
ra.Append(refSymbolAnchorLeft.GetReference())
ra.Append(lineSymbolVerticalCenter.GeometryCurve.Reference)
dimline = Line.CreateBound(XYZ(-3, -1, 0), XYZ(2, -4, 0))
dim = doc.FamilyCreate.NewLinearDimension(cView, dimline, ra)


t.Commit()

 

0 Likes
Accepted solutions (1)
410 Views
6 Replies
Replies (6)
Message 2 of 7

crapai
Advocate
Advocate

Testing to add the dimension type even thought here is a method that uses the default dimension and no luck. I printed out all the input to check if it was all there but nothing.

 

<Autodesk.Revit.DB.ViewPlan object at 0x0000000000001CC8 [Autodesk.Revit.DB.ViewPlan]>

<Autodesk.Revit.DB.Line object at 0x0000000000001CC9 [Autodesk.Revit.DB.Line]>

<Autodesk.Revit.DB.ReferenceArray object at 0x0000000000001CCA [Autodesk.Revit.DB.ReferenceArray]>

<Autodesk.Revit.DB.DimensionType object at 0x0000000000001CCB [Autodesk.Revit.DB.DimensionType]>

IronPython Traceback:
Traceback (most recent call last):
 File "L:\Revit\Development\PyRevit\DevTool\DevTool.extension\DevTools.tab\Development.Panel\JustTesting.pushbutton\JustTesting_script.py", line 90, in <module>
Exception: One of the conditions for the inputs was not satisfied. Consult the documentation for requirements for each argument.

 

0 Likes
Message 3 of 7

rcrdzmmrmnn
Advocate
Advocate

Are you sure the line used to create the dimension position is perpendicular to the reference line and plane?

rcrdzmmrmnn_0-1742393569035.png

 

0 Likes
Message 4 of 7

crapai
Advocate
Advocate

crapai_0-1742394226886.png

I fixed that a bit ago but still getting this error. The line should now be -3, -4 to 2, -4. I've also tried switching the points and lowering them, even though I don't think that would do anything.

t = Transaction(doc, "pyRevit - Create Reference Plane")
famMan = doc.FamilyManager
#dimType = FilteredElementCollector(doc).OfClass(DimensionType).
dimTypeId = doc.GetDefaultElementTypeId(ElementTypeGroup.LinearDimensionType)
dprint(dimTypeId)
dimType = doc.GetElement(dimTypeId)



t.Start()
# Parameters
# Label __ Left Right
famMan.AddParameter("Label __ Left Right", GroupTypeId.Constraints, SpecTypeId.Length, True)
# Label __ Off Wall
famMan.AddParameter("Label __ Off Wall", GroupTypeId.Constraints, SpecTypeId.Length, True)
# Label_Dim_LeftCorrection
famMan.AddParameter("Label_Dim_LeftCorrection", ForgeTypeId(), SpecTypeId.Length, True)
# Label_Dim_OffsetFromWallCorrection
famMan.AddParameter("Label_Dim_OffsetFromWallCorrection", ForgeTypeId(), SpecTypeId.Length, True)


p = Plane.CreateByNormalAndOrigin(XYZ.BasisZ, XYZ(0, 0, 0))
sp = SketchPlane.Create(doc, p)

# Ref Plane Label Anchor
refSymbolAnchorLeft = doc.FamilyCreate.NewReferencePlane(XYZ(-3,-1,0),XYZ(-3,1,0), XYZ(0,0,1), cView)
refSymbolAnchorLeft.Name = "Symbol Anchor"
refSymbolAnchorLeft.Pinned = True
refSymbolAnchorLeft.LookupParameter("Is Reference").Set(12)

# Ref Line Label Vertical Center
lsvc = Line.CreateBound(XYZ(2, -2, 0), XYZ(2, -4, 0))
lineSymbolVerticalCenter = doc.FamilyCreate.NewModelCurve(lsvc, sp)
lineSymbolVerticalCenter.ChangeToReferenceLine()

# Create Dimension
ra = ReferenceArray()
ra.Append(refSymbolAnchorLeft.GetReference())
ra.Append(lineSymbolVerticalCenter.GeometryCurve.Reference)
dimline = Line.CreateBound(XYZ(-3, -4, 0), XYZ(2, -4, 0))

dprint(cView)
dprint(dimline)
dprint(ra)
dprint(ra.IsEmpty)
dprint(ra.Size)
dprint(ra.Item[0])
dprint(ra.Item[1])
dprint(dimType)
dim = doc.FamilyCreate.NewLinearDimension(cView, dimline, ra, dimType)

t.Commit()

 

 

 

 

 

 

 

0 Likes
Message 5 of 7

crapai
Advocate
Advocate
Accepted solution

Turns out the references weren't working because they didn't exist due to them not being committed. I ending up using subtransactions and regenerate to get the lines to be committed before adding the dimension.

0 Likes
Message 6 of 7

rcrdzmmrmnn
Advocate
Advocate

Nice, gratz for solving. For Document.Regenerate() ,I know that Transactions automatically regenerate the document, but not sure if subtransactions do that also. Maybe you could try removing it, would shave some milliseconds 😂
Anyways, good job

0 Likes
Message 7 of 7

crapai
Advocate
Advocate

Originally didn't have the regenerate. So, I had to add it.