- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm getting a "magic" Error in Revit2023 :"The dimension type is a non-linear dimension type" using the attached code. The dimension type is linear, the number of references is equal 2 ... Any suggestions ?
Public Sub AddDim()
Dim r As Reference = _uiDoc.Selection.PickObject(ObjectType.Face, "Select a face")
Dim e As Element = _uiDoc.Document.GetElement(r)
Dim view As View = _uiDoc.ActiveView
Dim oFace As Face = e.GetGeometryObjectFromReference(r)
Dim edges As EdgeArray = oFace.EdgeLoops(0)
Dim dimensionStyle As DimensionType = New FilteredElementCollector(view.Document).OfClass(GetType(DimensionType)).Cast(Of DimensionType)().FirstOrDefault
'Dim offset As Double = 0
MessageBox.Show(view.Name.ToString) 'CHECK
Using trans As New Transaction(_doc, "Add Wall Dimensions")
trans.Start()
If dimensionStyle Is Nothing Then
Throw New Exception("No dimension style found in document")
End If
MessageBox.Show(dimensionStyle.Name.ToString)
For Each edge As Edge In edges
MessageBox.Show(edge.ApproximateLength.ToString) 'ONLY INFO
Dim eline As Curve = CType(edge.AsCurve(), Curve)
Dim pts As XYZ
Dim pte As XYZ
pts = eline.GetEndPoint(0)
pte = eline.GetEndPoint(1)
MessageBox.Show(pts.ToString & pte.ToString) 'ONLY INFO
Dim refArray As ReferenceArray = New ReferenceArray()
' Check whether eline is a line and add the endpoints to the reference array
If TypeOf eline Is Line Then
Dim line As Line = CType(eline, Line)
refArray.Append(line.GetEndPointReference(0))
refArray.Append(line.GetEndPointReference(1))
Else
refArray.Append(eline.GetEndPointReference(0))
refArray.Append(eline.GetEndPointReference(1))
End If
MessageBox.Show(refArray.Size.ToString) 'ONLY INFO
If refArray.Size = 2 Then
Dim dimRef As Dimension = _doc.Create.NewDimension(view, eline, refArray, dimensionStyle) 'Error in Revit2023 :"The dimension type is a non-linear dimension type"
End If
Next
trans.Commit()
End Using
End Sub
Solved! Go to Solution.
Developer Advocacy and Support,