## Misc_SS.py Version 1.01
## Copyright (c) 2006
Bruce Vaughan, BV Detailing & Design, Inc.
## All rights
reserved.
## NOT FOR
############################################################################
"""
The original intent of this script is to apply a shear stud pattern to an
existing rectangular plate miscellaneous member.
The script will add a shear stud pattern to
Misc, Column, and Beam members.
The script will apply the studs perpendicular to the miscellaneous member line in the
view that the member was entered
(member elevation
or initial main view in member isolate).
The script will allow input of stud
diameters 3/8" - 1". Function stud_dim() returns head
dimensions based upon the diameter
per published
Nelson Stud Welding data.
R2 -
Modify code to allow studs to be applied to face of material opposite
member line. Add option to orientate studs
horizontally
(Above or Below) or vertically (Near Side or Far Side). For Misc
members, this orientation is relative
to the
view in which the member line was entered (initial main member view). If the
member line was entered in plan,
horizontal
is true horizontal. Offsets to first stud relative to member start point are +x
and -z for Above and Below
orientations
and +x and -y for Near Side and Far Side orientations.
R3 -
Add option to apply to all members with the same piecemark
R4 -
Add option to select Beam, Column, or Misc
member
V7R1 - Test in
Version 1.00 (
Version 1.01 (
Add ClearSelection()
in try/finally block
This source is provided "as
is." All warranties are disclaimed.
Originally developed in
Developed by Bruce Vaughan, BV Detailing
& Design, Inc. (BVD)
For comments, suggestions or questions call
BVD at the number above.
NOT FOR
Go to Defaults section to modify script
defaults.
"""
# startup code begin
import os
from macrolib.FileDefaults
import import_data, export_data
# macrolib.pickle required
from macrolib.MemSelection
import mem_select
from macrolib.stud_info
import stud_dim
from param import ClearSelection, Dialog, yes_or_no,
dim_print, Units, dim
Units("feet")
from point import Point, PointLocate
from member import Member, MemberLocate
from shr_stud import
ShrStud
# startup code end
def run_script():
#############################################################################################################################
# Function definitions
def apply_stud(mem, pt11, pt12, _stud_diam, _head_thk, _head_diam, _stud_color, rot_args):
# shear stud
begin
m1 = ShrStud()
m1.member = mem
m1.pt1 = pt11
m1.pt2 = pt12
m1.stud_dia = _stud_diam
m1.head_thick = _head_thk
m1.head_dia = _head_diam
m1.length = m1.pt1.dist(m1.pt2)
m1.mtrl_type = "Shear stud"
m1.finish = _stud_color
m1.ref_pt_offset = (0.000000, 0.000000,
0.000000)
m1.add()
m1.rotate(m1.member,
rot_args)
# shear stud
end
# end function
definitions
## Variables Section
################################################
# system path for
defaults file
default_file_path
= os.path.join(os.getcwd(), "macro",
"Defaults")
# defaults file
def_file =
"Misc_SS.txt"
# Dialog box image path and file name
image_path = os.path.join(os.getcwd(), "macro", "Images")
#
image_name = os.path.join(image_path, "Misc_SS.gif")
image_name1 = os.path.join(image_path, "Misc_SS1.gif")
# default to
enable or disable the importing and exporting of dialog dictionary variables
"Enable" "Disable"
enable_default_import_export
= "Enable"
finishList =
["None", "Red Oxide", "Yellow Zinc", "Gray
Oxide", "Sandblasted", "Blued Steel",
"Galvanized"]
sideList
= ["Below", "Above", "Near Side", "Far
Side"]
#################################################################
# Defaults section
# if 'stud_diam' not in globals().keys():
# stud diameter
("1/4", "3/8", "1/2", "5/8",
"3/4", "7/8", "1")
stud_diam =
"3/4"
# stud length
stud_length = 8.0
stud_color =
"Yellow Zinc"
# offset from mem1.pt1 to first stud along
miscellaneous member x-axis
x_off = 2.0
# offset from mem1.pt1 to first stud along
miscellaneous member z-axis
z_off = 4.0
# stud spacing along miscellaneous member
x-axis
x_spa = 8.0
# stud spacing along miscellaneous member
z-axis
z_spa = 6.0
# number of stud
columns along miscellaneous member x-axis
no_cols = 2
# number of stud
rows along miscellaneous member z-axis
no_rows = 1
# "Below", "Above",
"Near Side", "Far Side"
which_side =
"Far Side"
# offset relative to member line (plate
thickness)
y_off = 0.0
# end script
defaults
#####################################################################
## Import defaults data if enabled
if enable_default_import_export == "Enable":
dd0 = import_data(os.path.join(default_file_path, def_file))
if dd0:
for key,
value in dd0.items():
exec
"%s = %s" % (key, repr(value)) in None
#####################################################################
##
while True:
ClearSelection()
misc_list = mem_select("Select
Beam, Column, or Misc Member to Apply Stud
Pattern", ['Beam', 'Column', 'Misc'],
["All", ])
if misc_list is None:
break
mem1 = misc_list[0]
# determine stud dimensions based upon
stud diameter
head_thk, head_diam, burn_off = stud_dim(dim(stud_diam))
#############################################################
## DIALOG
#############################################################
dlg1 = Dialog(
"Add a stud pattern" )
dlg1.menu("print_doc", ("Yes", "No"),
"No", "Print documentation only")
dlg1.tabset_begin()
dlg1.tab("Data")
dlg1.group_title("Stud
Pattern Orientation, Stud Dimensions, and Material Color")
dlg1.menu("which_side", sideList, which_side, "Apply studs to which side of member line
elevation")
dlg1.label(dim_print(head_diam) + " diam. x " + dim_print(head_thk), "Stud head dimensions for default stud
diameter: ")
dlg1.label(dim_print(burn_off), "Burn
off for default diameter: ")
dlg1.menu("stud_diam", ("1/4", "3/8", "1/2",
"5/8", "3/4", "7/8", "1"), dim_print(stud_diam), "Stud
diameter")
dlg1.entry("stud_length", dim_print(stud_length), "Stud length")
dlg1.menu("stud_color", finishList, stud_color, "Color of stud material")
dlg1.group_title("Stud
Pattern - Anchor Point is Member Start Point")
dlg1.label(dim_print(mem1.left_location.x) + " , " + dim_print(mem1.left_location.y) + " , " + dim_print(mem1.left_location.z), "Anchor Point:
")
dlg1.label(dim_print (mem1.left.location.dist(mem1.right.location)),
"Member Line True Length: ")
dlg1.entry("no_cols", no_cols,
"Number of stud columns (member '+x' direction) ")
dlg1.entry("no_rows", no_rows,
"Number of stud rows (member 'y' or '-z' direction)")
dlg1.entry("y_off", dim_print(y_off), "Material face offset (0 if face is on mem line)")
dlg1.group_title("Stud
Columns (member 'x')")
dlg1.entry("x_off", dim_print(x_off), "First stud '+x' location")
dlg1.entry("x_spa", dim_print(x_spa), "Column spacing")
dlg1.group_title("Stud
Rows (member 'y')")
dlg1.entry("z_off", dim_print(z_off), "First stud '-y' or '-z' location")
dlg1.entry("z_spa", dim_print(z_spa), "Row spacing")
dlg1.tab("Image")
dlg1.image(image_name)
dlg1.tab("Screenshot")
dlg1.group_title("Stud
pattern data: 3, 1, 5, -3 1/4, 3'-0, 0, 1/4")
dlg1.image(image_name1)
dlg1.tabset_end()
try:
dd1 = dlg1.done()
except ResponseNotOK:
break
# Update the local namespace for next
loop
for key, value
in dd1.items():
exec
"%s = %s" % (key, repr(value)) in None
###############################################################
## END DIALOG
###############################################################
if print_doc == "Yes":
print
__doc__
break
###############################################################
# Export defaults to disk if enabled
if enable_default_import_export == "Enable":
export_data(os.path.join(default_file_path, def_file),
dd1)
###############################################################
if which_side == "Above" or which_side
== "Near Side":
y_factor
= -1
else:
y_factor
= 1
head_thk, head_diam, burn_off = stud_dim(dim(stud_diam))
if which_side == "Above":
rot_mat =
(0.000000, 0.000000, 90.000000)
elif
which_side == "Below":
rot_mat =
(0.000000, 0.000000, -90.000000)
elif which_side
== "Near Side":
rot_mat =
(0.000000, 90.000000, 0.000000)
else:
rot_mat =
(0.000000, -90.000000, 0.000000)
for mem in misc_list:
if which_side == "Above" or which_side
== "Below":
pt1 = mem.left_location
+ mem.translate(x_off, -y_off
* y_factor, -z_off)
else:
pt1 = mem.left_location
+ mem.translate(x_off, -z_off,
-y_off * y_factor)
x_dist =
0.0
for i in range(no_cols):
z_dist
= 0.0
x_dist
= i*x_spa
for j
in range(no_rows):
z_dist
= j*z_spa
if
which_side == "Above" or which_side == "Below":
ptWP = pt1 + mem.translate(x_dist, 0.0, -z_dist)
else:
ptWP = pt1 + mem.translate(x_dist, -z_dist, 0.0)
apply_stud(mem,
ptWP, ptWP + mem.translate(stud_length, 0.0,
0.0), \
dim(stud_diam), head_thk, head_diam, stud_color, rot_mat)
if not yes_or_no("Select another Beam, Column, or Misc Member?"):
break
## End run_script()
if __name__ == '__main__':
try:
run_script()
finally:
ClearSelection()