Set Floor Span Direction Symbol

Set Floor Span Direction Symbol

mphelt
Participant Participant
7,075 Views
5 Replies
Message 1 of 6

Set Floor Span Direction Symbol

mphelt
Participant
Participant

Is there any chance to create or otherwise set Span Direction Symbol for Floor?

I create Floor using Create.NewFloor and then set Floor.SpanDirectionAngle property.

But doing this, when I try to manually edit sketch from the UI, I can't see the span direction symbol anywhere.

How to achieve that?

0 Likes
7,076 Views
5 Replies
Replies (5)
Message 2 of 6

Joe.Ye
Alumni
Alumni

 

Hi there,

 

Not sure what's cause.

 

The following code can successfully create a floor and set the span direction. After creating the floor, and edit the floor, I can see the span symbol in the floor editor.

 

Here is the code.

 

<code>

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

using Autodesk.Revit .DB;
using Autodesk.Revit.UI;
using Autodesk.Revit .ApplicationServices;
using Autodesk.Revit.Attributes ;
using Autodesk.Revit.UI.Selection;


[TransactionAttribute(TransactionMode.Manual)]
public class RevitCommand : IExternalCommand
{
public Result Execute(ExternalCommandData commandData,
ref string messages, ElementSet elements)
{

UIApplication app = commandData.Application;
Document doc = app.ActiveUIDocument.Document;

Transaction trans = new Transaction(doc);
trans.Start("CreateFloorChangeSpanDirection");

//create a floor.
CurveArray ca = new CurveArray();
double width = 5;

Line l1 = Line.CreateBound(new XYZ(width, width, 0), new XYZ(width, -width, 0));
Line l2 = Line.CreateBound(new XYZ(width, -width, 0), new XYZ(-width, -width, 0));
Line l3 = Line.CreateBound(new XYZ(-width, -width, 0), new XYZ(-width, width, 0));
Line l4 = Line.CreateBound(new XYZ(-width, width, 0), new XYZ(width, width, 0));

ca.Append(l1);
ca.Append(l2);
ca.Append(l3);
ca.Append(l4);

Floor f = doc.Create.NewFloor(ca, false);

f.SpanDirectionAngle = 0;
trans.Commit();


return Result.Succeeded ;
}
}

 

<code>



Joe Ye
Contractor
Developer Technical Services
Autodesk Developer Network
0 Likes
Message 3 of 6

ellen.cummings
Explorer
Explorer

Hi, 

 

We are currently experiencing the same issue. 

 

If you try a non-zero value then the Structural Floor Span Direction does not seem to be set when you attempt to edit the slab geometry (Modify > Edit Boundary > Select green tick without making any changes) - see error that occurs in screenshot below.

 

Please note that when you show the slab direction using Annotate > Span Direction > Auto place ON, the span direction symbols are added as you would expect. Span Direction.JPG

 

Message 4 of 6

abdelrahmanfathe95
Participant
Participant

spanDirection is not set set in the scketch plane when changing SpanDirectionAngle property.

0 Likes
Message 5 of 6

RPTHOMAS108
Mentor
Mentor

Yes seems like an error. However as a workaround if you change the span direction in a separate transaction after creating the slab then the span direction line is correctly created (use of a subtransaction doesn't resolve the issue in the same way).

 

This is a rare example of being able to do something in the API that you can't do in the UI i.e. complete a slab sketch without a span direction line.

 

 

Public Function TObj105(ByVal commandData As Autodesk.Revit.UI.ExternalCommandData,
ByRef message As String, ByVal elements As Autodesk.Revit.DB.ElementSet) As Result

        Dim Doc As Document = commandData.Application.ActiveUIDocument.Document
        Dim UIDoc As UIDocument = commandData.Application.ActiveUIDocument
        Dim Width As Double = 10

        Dim LN1 As Line = Line.CreateBound(New XYZ(Width, Width, 0), New XYZ(Width, -Width, 0))
        Dim LN2 As Line = Line.CreateBound(New XYZ(Width, -Width, 0), New XYZ(-Width, -Width, 0))
        Dim LN3 As Line = Line.CreateBound(New XYZ(-Width, -Width, 0), New XYZ(-Width, Width, 0))
        Dim LN4 As Line = Line.CreateBound(New XYZ(-Width, Width, 0), New XYZ(Width, Width, 0))

        Dim CA As New CurveArray
        CA.Append(LN1)
        CA.Append(LN2)
        CA.Append(LN3)
        CA.Append(LN4)
        Dim Flr As Floor = Nothing

        Using Tx As New Transaction(Doc, "Floor")
            If Tx.Start = TransactionStatus.Started Then
                Flr = Doc.Create.NewFloor(CA, True)
                Tx.Commit()
            End If
        End Using

        If Flr Is Nothing = False Then
            Using Tx1 As New Transaction(Doc, "Add span direction")
                If Tx1.Start = TransactionStatus.Started Then
                    Flr.SpanDirectionAngle = Math.PI / 4
                    Tx1.Commit()
                End If
            End Using
        End If

        Return Result.Succeeded
    End Function

 

 

 

 

 

Message 6 of 6

abdelrahmanfathe95
Participant
Participant

Thanks, so much you really saved my day today. 

0 Likes