Placing switches near doors

Hi all , I am trying to write a code to place switches near the doors(200 mm away from door and 1200mm height).As an initial step ,I’m getting the location of door and trying to translate point to 200mm after adding the half width of door.Now I am stuck to find a vector along the wall to translate the point along the direction as desired.Any help?
image

UIunit = Document.GetUnits(doc).GetFormatOptions(UnitType.UT_Length).DisplayUnits

# The inputs to this node will be stored as a list in the IN variables.

Door = UnwrapElement(IN[0])


# Place your code below this line

Location_Point = Door.Location.Point
Door_TypeId = Door.GetTypeId()
Door_Type = doc.GetElement(Door_TypeId)



Para_Width = Door_Type.LookupParameter("Width")
Para_WidthValue = Para_Width.AsDouble()
Para_WidthValueInmm = Para_WidthValue*304.8
Width_Half = Para_WidthValueInmm/2



HostWall = 	Door.Host
Location_Curve = HostWall.Location.Curve
Vector_ = Location_Curve.Direction



pt_Dyn = Autodesk.DesignScript.Geometry.Point.ByCoordinates(UnitUtils.ConvertFromInternalUnits(Location_Point.X,UIunit),UnitUtils.ConvertFromInternalUnits(Location_Point.Y,UIunit),UnitUtils.ConvertFromInternalUnits(Location_Point.Z,UIunit))

# Assign your output to the OUT variable.
OUT = pt_Dyn,Vector_,Width_Half

switches Testing.dyn (14.1 KB)

Hi,

replace this line by

Vector_ = Location_Curve.Direction.ToVector()

see here

4 Likes

Thank You.