Problem about Orientation by vector/plane

Hello everyone

I am working on getting the orientation of the sections.

As I worked in it, I find that I cant outcome a result larger than 180. (The green words represents what I want)


The following is my sript. Is there any way to obtain orientation larger than 180 degree in dynamo?

Hi @TCKEAHY

use Vector.AngleAboutAxis instead. The node used in your script as far I remember defines angle only between 0 and 180.

1 Like

@TCKEAHY ,

Maybe you can integrate this concept…

KR

Andreas

  1. Select Section Markers
  2. Gather all Section Views in the Project and their names.
  3. Extract which Section View the Marker relates to.
  4. Find the Section View ViewDirection and reverse this away from the viewer.
  5. Compare the new ViewDirection angle to a temporary Plane (XZ Axis).
  6. Process for unit conversion from internal units to degrees.
  7. Apply some logic for converting the negative vectors to the angle numbering scheme you proposed in your image.
  8. Happy Days :slight_smile:
import clr
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication 
app = uiapp.Application 
uidoc = uiapp.ActiveUIDocument

import math

#input
sectionMarkers = UnwrapElement(IN[0])

# Get all section views
allSectionViews = FilteredElementCollector(doc).OfClass(ViewSection).ToElements()

# Get all section view names
allSectionViewNames = []
for a in allSectionViews:
    allSectionViewNames.append(a.Name)

result = []

for s in sectionMarkers:
    
    # Get the View Name of the marker
    sn = s.Name
    snIndex = allSectionViewNames.index(sn)
    sectionView = allSectionViews[snIndex]
    
    # Get the right direction of the section view
    sectionRDir = sectionView.ViewDirection.Negate()
    
    # Compare the vector to an XZ plane
    angle = sectionRDir.AngleOnPlaneTo(XYZ(0,1,0),XYZ(0,0,1))
    degAngle = round(math.degrees(angle))-90
    
    # Allow for rotation angle sorting
    if degAngle < 0:
        finalAngle = 360 + degAngle
    else:
        finalAngle = degAngle
        
    result.append(finalAngle)
    

OUT = result
3 Likes