Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

SlabShapVertexArray don't work for me

Anonymous

SlabShapVertexArray don't work for me

Anonymous
Not applicable

Hello,

 

In one of my plugin i would like to move floor vertex height, so I used this line : 

 

SlabShapeVertexArray slabShapeVertexArray = floor.SlabShapeEditor.SlabShapeVertices;

 

in order to get the vertex array and I used a "for" loop to get each vertex :

 

             for (int i = 0; i < slabShapeVertexArray.Size; ++i)
            {
                SlabShapVertex vertex = slabShapeVertexArray.get_Item(i);

            }

 

but i never goes in the loop, so I i check the value of slabShapeVertexArray.Size and it's equal to 0;

 

Can someone help me Because i Don't know why i can't get the vertices

0 Likes
Reply
754 Views
3 Replies
Replies (3)

RPTHOMAS108
Mentor
Mentor

Did you call SlabShapeEditor.Enable?

 

Note that you can't use this on a slab with a slope set by sketch.

0 Likes

Anonymous
Not applicable

No, i didn't call this method, but i've tried and it Don't change anything, the size field is still equal to 0.

 

I already use the slabShapEditor.drawPoint and it works, but the SlabShapVertexArray does not contain any Vertex

0 Likes

RPTHOMAS108
Mentor
Mentor

Yeah I see why.

 

You have to call Document.Regenerate if you are Enabling a slab not already enabled and manipulating the SubElements in the same transaction.

 

Private Function TObj137(ByVal commandData As Autodesk.Revit.UI.ExternalCommandData,
ByRef message As String, ByVal elements As Autodesk.Revit.DB.ElementSet) As Result
        If commandData.Application.ActiveUIDocument Is Nothing Then Return Result.Cancelled Else
        Dim UIDoc As UIDocument = commandData.Application.ActiveUIDocument
        Dim IntDoc As Document = commandData.Application.ActiveUIDocument.Document
        Dim AcView As View = UIDoc.ActiveGraphicalView
        Dim R1 As Reference = Nothing
        Try
            R1 = UIDoc.Selection.PickObject(Selection.ObjectType.Element)
        Catch ex As Exception
        End Try
        If R1 Is Nothing Then Return Result.Cancelled Else

        Dim El As Floor = TryCast(IntDoc.GetElement(R1), Floor)
        If El Is Nothing Then Return Result.Cancelled Else

        Using tx As New Transaction(IntDoc, "Edit slab")
            If tx.Start = TransactionStatus.Started Then

                If El.SlabShapeEditor Is Nothing Then
                    tx.RollBack()
                End If
                If El.SlabShapeEditor.IsEnabled = False Then
                    El.SlabShapeEditor.Enable()
                End If

                If El.SlabShapeEditor.SlabShapeVertices.Size = 0 Then
                    IntDoc.Regenerate()
                End If
                For I = 0 To El.SlabShapeEditor.SlabShapeVertices.Size - 1
                    Dim Vx As SlabShapeVertex = El.SlabShapeEditor.SlabShapeVertices(I)
                    If I = 1 Then
                        El.SlabShapeEditor.ModifySubElement(Vx, 0.5)
                    End If
                Next
                tx.Commit()
            End If
        End Using
        Return Result.Succeeded
    End Function

 

0 Likes