I want to calculate a line at 30 degrees.
for example one line is 36" where would the line be 90 degrees from there at 30 degrees.
excel formula is
=TAN(RADIANS(30))*36
which will give me
20.7846096908265
Thanks for looking.
I want to calculate a line at 30 degrees.
for example one line is 36" where would the line be 90 degrees from there at 30 degrees.
excel formula is
=TAN(RADIANS(30))*36
which will give me
20.7846096908265
Thanks for looking.
I have HTML code to create a webdialog form.
How do I Make a face with these points and Use the pushpull selection and create the group name---when I click the button?
require 'Sketchup'
def show_dialog
dlg = UI;;WebDialog.new("DialogTest", false,
"DialogTest", 600, 150, 150, 150, true);
html = <<-HTML
<form>
<body>
<div class="style1" style="width; 511px; height; 70px">
<label id="Label1">Name 1
pt1 pt2
pt3
pt4
Thick<br>
</label>
<input name="Group1" type="text" value="Group1" style="width; 62px" />
<input name="pt1" type="text" class="style2" style="width; 46px" value="(0,0,0)" />
<input name="pt2" type="text" style="width; 54px; height; 22px" value="(0,10,0)" />
<input name="pt3" type="text" style="width; 63px" value="(0,10,10)">
<input name="pt4" type="text" style="width; 58px" value="(0,10,0)">
<select name="pushpull" style="width; 65px">
<option></option>
<option selected="">1</option>
<option>2</option>
<option>3</option>
</select> <input name="OK" type="button" value="button"></div>
<p> </p>
</body>
</form>
HTML
dlg.set_html html
dlg.add_action_callback("ruby_messagebox") {|dialog, params|
UI.messagebox("You called ruby_messagebox with; " + params.to_s)
}
dlg.show
end
show_dialog
Thanks
Is it possible to saveas a workbook from input box?
Something like this is what I'm trying to do.
prompts = ["Top Hanger Thickness","Customer Address"]
defaults = [3.0, "Howdy"]
input = UI.inputbox prompts, defaults, "Stair Info"
a,b=input
require('win32ole')
excel = WIN32OLE.new('Excel.Application')
excel.Visible = true
number_of_sheets = excel.SheetsInNewWorkbook
excel.SheetsInNewWorkbook = 1
workbook = excel.Workbooks.Add
excel.SheetsInNewWorkbook = number_of_sheets
ws = workbook.Worksheets(1)
ws.Cells(1,1).Value = b
# workbook.SaveAs({C;\TestFolder\} b & ".xlsx")#trying to get 'Customer Address' as the saved workbook
## workbook.SaveAs("#{pwd}whatever.xlsx",
Thanks
x=(25/8).ceil #returns 3 y=(25/8).round # returns 3
These are the only functions I can find. I need x/8 to roundup to the next whole number.
Thanks for looking
@slbaumgartner said:
....
Thanks alot,
How do I pushpull this?
I am trying
finaledge.pushpull 1
and
face.pushpull 1
nothing seems to be happening.
I have this one scripts,
UI.menu("PlugIns").add_item("Draw Riser") { draw_riser }
def draw_riser
prompts = ["length", "Run","height","Rise","Total Rises","Riser Thickness"]
defaults = [36.0,10.0,1.0,7.75,7,0.5]
input = UI.inputbox prompts, defaults, "Risers."
a,b,c,d,e,f=input
ent = Sketchup.active_model.entities
#---------Clear All
#Sketchup.active_model.entities.clear!
#----------------Make 1st Riser
ent.add_line [0,0,d-c+0.1875], [0,0,0]
ent.add_line [0,-0.5,d-c+0.1875], [0,-0.5,0]
ent.add_line [0,0,0], [0,-0.5,0]
ent.add_line [0,0,d-c+0.1875], [0,-0.5,d-c+0.1875]
#edg.find_faces; face=edg.faces[0]
#face.pushpull a
##group5 = ent.add_group face.all_connected
#----------------Make rest of Risers
ent.add_line [0,b,2*d-c+0.1875], [0,b,d-c]
ent.add_line [0,-0.5+b,2*d-c+0.1875], [0,-0.5+b,d-c]
ent.add_line [0,b,d-c], [0,-0.5+b,d-c]
ent.add_line [0,b,2*d-c+0.1875], [0,-0.5+b,2*d-c+0.1875]
# edg.find_faces; face=edg.faces[0]
#face.pushpull a
#group3 = ent.add_group face.all_connected
#for i in 1..e-2
# group5 = group4.copy
# tran = Geom;;Transformation.translation [0, b*i, d*i]
#group5.transform! tran
#end
end
Im having issues getting the code to make the faces and then pushpull.
My idea is to make the 1st riser a group on it's own, then make the second riser a group and copy it up.
Thanks
Very nice indeed. I adjusted it to account for the riser thickness, this needs to be cut off at the back. And it does work for any size string.
thanks.
How can I change the basepoint from original to (0,1+rise_thickness,0) ?
def draw_stringer(rise, run, tread_thickness, numsteps)
ents=Sketchup.active_model.active_entities
rise=7.75
run=10
tread_thickness=1
numsteps=7
string=11
rise_thickness=0.5
# offset vectors for rise and run
risevect = Geom;;Vector3d.new([0,0,0], [0,0,rise])
runvect = Geom;;Vector3d.new([0,0,0], [0,run,0])
#<<<<<<<<<<<<<<
lstrun = Geom;;Vector3d.new([0,0,0], [0,(run-rise_thickness),0])
#<<<<<<<<<<<<<<<<<<<<
# arbitrarily start at the global SketchUp origin
basepoint = ORIGIN
# draw the upper profile of the stringer
# first step adjusted for tread thickness
corner = basepoint.offset(Geom;;Vector3d.new([0,0,0], [0,0,rise-tread_thickness]))
ents.add_line(basepoint, corner)
# remember first corner for later
firstcorner = corner
basepoint = corner.offset(runvect)
ents.add_line(corner, basepoint)
# now do the rest of the steps
2.upto(numsteps-2) do
corner = basepoint.offset(risevect)
ents.add_line(basepoint, corner)
basepoint = corner.offset(runvect)
ents.add_line(corner, basepoint)
end
# <<<<<<<<<<<<last run
corner = basepoint.offset(risevect)
ents.add_line(basepoint, corner)
basepoint = corner.offset(lstrun)
ents.add_line(corner, basepoint)
# create the baseline and top plumb line
baseline = [ORIGIN, [0,1,0]]
plumbline = [basepoint, [0,0,-1]]
# create the offset vector to the other line
cornervect = Geom;;Vector3d.new(firstcorner, corner)
normalvect = cornervect*[0,0,1]
offsetvect = cornervect*normalvect
offsetvect.length=string
# create the two corners for the remaining Edges
# get a point on the bottom line by offsetting from any top corner
refpoint = corner.offset(offsetvect)
oppline = [refpoint, cornervect]
bottomcorner = Geom;;intersect_line_line(oppline, baseline)
topcorner = Geom;;intersect_line_line(oppline, plumbline)
# add the Edges
ents.add_line(ORIGIN, bottomcorner)
ents.add_line(bottomcorner, topcorner)
finaledge = ents.add_line(topcorner, basepoint)
# fill in the Face
finaledge.find_faces()
end
Thanks,I still need the required depth 11". That would be where the math would come in.
@jolran said:
Ah, doh. I missread. You want an edge, not an infinite line.
Well I was first trying figure out where to put the line, then I was going to try and figure out how the bottom and top lines meet it.(as per image)
Using this
x=10
y=7.75
ent = Sketchup.active_model.entities
ent.add_line [0,0,0], [0,x,y]
x = Math;;atan(y/x).radians
I can figure out the angle (37.77568430595466) for this example.
Maybe if I subtract that degree from 90. (52.22431569404534).
How do I find those points?
something like 11*52.22431569404534 degrees.
Am I even on the right path?
Not sure yet.
this is what I am trying to do, please refer to pic
https://drive.google.com/file/d/0ByXxMRXssekcR1hkalFYZHdLRUU/view?usp=sharing
I am trying to get the bottom lines
` prompts = ["length", "Run","height","Rise","Total Rises"]
defaults = [36.0,10.0,1.0,7.75,7]
input = UI.inputbox prompts, defaults, "Tread."
a,b,c,d,e=input
ent = Sketchup.active_model.entities
#---------Clear All
#Sketchup.active_model.entities.clear!
#----------------Make Bottom Stringer-----
ent.add_line [2,(b+1)+0b+0.5,0+0d-c], [2,(1.5+0b),0+0d-c]
ent.add_line [2,1.5+0b,-d], [2,1.5+0b,-c]
for i in 1..e-3
ent.add_line [2,(b+1)+i*b+0.5,0+i*d-c], [2,(1.5+i*b),0+i*d-c]
ent.add_line [2,1.5+i*b,0+i*d-c], [2,1.5+i*b,-d+(i*d)-c]
end
ent.add_line [2,((e-2)*b)+1.5,((e-2)*d)-1], [2,((e-1)*b)+1,((e-2)*d)-1]
ent.add_line [2,((e-2)*b)+1.5,((e-2)*d)-1], [2,((e-2)*b)+1.5,((e-3)*d)-1]`
thanks
The new line will be below the original line
ent = Sketchup.active_model.entities ent.add_line [0,0,0], [0,30,40]
What is the formula to draw a parallel line 11.
original points are given for the first line
The distance is given for the parallel line but what will the points be?
thanks
Dave
https://drive.google.com/file/d/0ByXxMRXssekcYzNRczMtVUR0RlE/view?usp=sharing
@jolran said:
One idea is starting using groups to organize your geometry.
Clearing everything on the screen, sounds like a dangerous approach to me.
Just a simple tip..ents = Sketchup.active_model.entities
gp = ents.add_group
ent = gp.entities
Thanks,
I'm just trying to find a way not to have to keep pressing 'Ctrl & "A" then delete, every time I want to test a code.
Excellent, thanks for the suggestion...it worked.
Just a side note, is there a "clear All" code that can run at the beginning of this code?
for example
` clear_all#< clears everything on the screen.
prompts = ["length", "width","height","Rise"]
defaults = [36.0,10.0,1.0,7.75]
input = UI.inputbox prompts, defaults, "Tread."
if input == false
UI.messagebox("All Must Be Entered")
else
a,b,c=input
#UI.messagebox("Tread input accepted!, #{input}!")
end
ent = Sketchup.active_model.entities
ent.add_line [0,b-c/2,0],[0,0,0]
ent.add_arc [0,0,c/2.0],[0,0,-1],[-1,0,0],c/2.0,0,180.degrees,20
ent.add_line [0,0,c],[0,b-c/2,c]
edg=ent.add_line [0,b-c/2,c],[0,b-c/2,0]
edg.find_faces; face=edg.faces[0]
#face = ent.add_face [0,0,0], [a,0,0], [a,b,0], [0,b,0]
#face.reverse!
face.pushpull -a`
Alright I can get the b=0.5 on the last loop but can't get it to the correct location, because I changed b to 0.5 !!!.
prompts = ["length", "Run","height","Rise","Total Rises"]
defaults = [36.0,10.0,1.0,7.75,7]
input = UI.inputbox prompts, defaults, "Tread."
a,b,c,d,e=input
k = 0 #<<--- start k=0
ent = Sketchup.active_model.entities
for i in 0..e-1
if k>e-2 then #<<<----if k=e-1
b = 0.5
end#<<<---
k=k+1
ent.add_line [0,(b+1)+i*b,0+i*d-1], [0,(1.5+i*b),0+i*d-1]
ent.add_line [0,1.5+i*b,0+i*d-1], [0,1.5+i*b,-d+(i*d)-1]
ent.add_line [0,1+i*b,0+i*d-1], [0,1+i*b,-d+(i*d)-1]
ent.add_line [0,1+i*b,-d+(i*d)-1], [0,1.5+i*b,-d+(i*d)-1]
edg = ent.add_line [0,1+i*b,-1+i*d],[0,0.5+i*b,-1+i*d];vrt1=edg.end
ent.add_arc [0,0.5+i*b,-c/2.0+(i*d)],[0,0,-1],[-1,0,0],c/2.0,0,180.degrees,12
edg = ent.add_line [0,0.5+i*b,0+i*d],[0,b+(i*b)+1,0+i*d];vrt2=edg.start
edg=ent.add_line [0,b+1+i*b,-c+i*d],[0,b+1+i*b,0+i*d]
edg.find_faces; face=edg.faces[0]
face.pushpull -a
edgs=vrt1.edges.reject!{|e| e.length<a};edgs[0].soft=true
edgs=vrt2.edges.reject!{|e| e.length<a};edgs[0].soft=true
#group1 = ent.add_group face.all_connected
end