SHARE
TWEET

Elevation Creation with elevation id outputs

a guest Dec 30th, 2016 130 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. toggle = IN[0]
  3. points = UnwrapElement(IN[1])
  4. modelPoints = UnwrapElement(IN[2])
  5. cropCurves = UnwrapElement(IN[3])
  6. viewType = UnwrapElement(IN[4])
  7.  
  8. lst = []
  9. viewid = []
  10. output = []
  11.  
  12. #Get Family View Type
  13. vft = 0
  14. collector = FilteredElementCollector(doc).OfClass(ViewFamilyType).ToElements()
  15.  
  16. #eleViews = []
  17. for i in collector:
  18.     if i.ViewFamily == ViewFamily.Elevation:       
  19.         vft = i.Id
  20.         break
  21.  
  22. if toggle == True:
  23.    
  24.     TransactionManager.Instance.EnsureInTransaction(doc)
  25.    
  26.     for ind, point in enumerate(points):
  27.    
  28.         #Retrieve the mid point of model lines and get X,Y.    
  29.         modelMP = modelPoints[ind].ToXyz()
  30.         modelMPX = modelMP.X
  31.         modelMPY = modelMP.Y
  32.        
  33.         #Retrieve individual lines of crop window.     
  34.         cropLines = cropCurves[ind]
  35.         l1 = cropLines[0].ToRevitType()
  36.         l2 = cropLines[1].ToRevitType()
  37.         l3 = cropLines[2].ToRevitType()
  38.         l4 = cropLines[3].ToRevitType()
  39.                    
  40.         # Create a line in the z-Axis for elevation marker to rotate around.           
  41.         elevationPT = point.ToXyz()
  42.         elptRotate = XYZ(elevationPT.X, elevationPT.Y, elevationPT.Z+100)
  43.         ln = Line.CreateBound(elevationPT, elptRotate)
  44.  
  45.         #Calculate the angle between Model Mid Point and Elevation Point.
  46.         elevationPTY = elevationPT.Y
  47.         elevationPTX = elevationPT.X                           
  48.         combY = elevationPTY-modelMPY
  49.         combX = elevationPTX-modelMPX          
  50.         ang = atan2(combY, combX)
  51.  
  52.         #Create elevation marker and elevation in position 0.
  53.         eleMarker = ElevationMarker.CreateElevationMarker(doc, viewType.Id, elevationPT, 100)
  54.         ele = eleMarker.CreateElevation(doc, doc.ActiveView.Id , 0)
  55.         viewid.append(ele)
  56.        
  57.         #Rotate elevation marker towars model line.
  58.         ElementTransformUtils.RotateElement(doc, eleMarker.Id, ln, ang)
  59.        
  60.         #  
  61.         crManager = ele.GetCropRegionShapeManager()
  62.         #crShape = crManager.GetCropRegionShape()
  63.  
  64.         newCurveLoop = []
  65.         newCurveLoop.Add(l1)
  66.         newCurveLoop.Add(l2)
  67.         newCurveLoop.Add(l3)
  68.         newCurveLoop.Add(l4)
  69.            
  70.         cLoop = CurveLoop.Create(newCurveLoop)
  71.  
  72.         try:           
  73.             crManager.SetCropRegionShape(cLoop)
  74.             lst.append("Elevation Created")
  75.        
  76.         except:
  77.             pass
  78.             lst.append("Missed Elevation")
  79.  
  80.     TransactionManager.Instance.TransactionTaskDone()
  81.    
  82.     output.append([lst,viewid])
  83.    
  84.     OUT = output
  85.    
  86.    
  87. else:
  88.  
  89.     OUT = "Set Run Gate to TRUE"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top