Ruby plugin?
-
Maybe a little concept image, because this plug is maybe yet existing
-
@unknownuser said:
Maybe a little concept image, because this plug is maybe yet existing
There is an Example in the attachment of what I would like to do with it.
-
for something like this it's probably quicker and easier to draw [rectangle tool] the profile, select all lines and click followMe tool.
there are lot of rubies that deal with more complex versions of this, but the standard tools can do quite a bit...
-
@driven said:
for something like this it's probably quicker and easier to draw [rectangle tool] the profile, select all lines and click followMe tool.
there are lot of rubies that deal with more complex versions of this, but the standard tools can do quite a bit...
[attachment=0:1tdufwpm]<!-- ia0 -->use_followMe.png<!-- ia0 -->[/attachment:1tdufwpm]This is somethin for my school project so to draw it this way it isn't an option
-
@thomas214 said:
@driven said:
for something like this it's probably quicker and easier to draw [rectangle tool] the profile, select all lines and click followMe tool.
there are lot of rubies that deal with more complex versions of this, but the standard tools can do quite a bit...
[attachment=0:3bwzyrmz]<!-- ia0 -->use_followMe.png<!-- ia0 -->[/attachment:3bwzyrmz]This is somethin for my school project so to draw it this way it isn't an option
So write down the plan for your code...
. check themodel.selection
contains some connectedEdge
s (>>>path)
. use aUI.inputbox()
dialog to get theheight
. add a rectangle_face atstart.position
(p0) of first edge in path, calculating the other three points asp0=p1.clone; p1.z=p1.z+height
etc usingrectangle_face=entities.add_face(p0,p1,p2,p3)
. use rectangle_face.followme(path) to extrude the new face along the path.
. done -
@tig said:
@thomas214 said:
@driven said:
for something like this it's probably quicker and easier to draw [rectangle tool] the profile, select all lines and click followMe tool.
there are lot of rubies that deal with more complex versions of this, but the standard tools can do quite a bit...
[attachment=0:2kbtp9i4]<!-- ia0 -->use_followMe.png<!-- ia0 -->[/attachment:2kbtp9i4]This is somethin for my school project so to draw it this way it isn't an option
So write down the plan for your code...
. check themodel.selection
contains some connectedEdge
s (>>>path)
. use aUI.inputbox()
dialog to get theheight
. add a rectangle_face atstart.position
(p0) of first edge in path, calculating the other three points asp0=p1.clone; p1.z=p1.z+height
etc usingrectangle_face=entities.add_face(p0,p1,p2,p3)
. use rectangle_face.followme(path) to extrude the new face along the path.
. doneHmmm what if I useEdge.all_connectedthen the code from the the plugin push/pull face I have?
-
I got this far
prompts = ["x:", "y:", "z:"]
defaults = [10, 20, 100]
input = UI.inputbox prompts, defaults, "Input data"
x = input[0]
y = imput[1]
z = imput[2]
model = Sketchup.active_model
ent = model.entities
sel = model.selectionmodel = Sketchup.active_model
entities = model.active_entities
pts = []
pts[0] = [0, 0, 0]
pts[1] = [x, 0, 0]
pts[2] = [x, y, 0]
pts[3] = [0, y, 0]Add the face to the entities in the model
face = entities.add_face pts
I just happen to know that the second and third entities in the
entities objects are edges.
entity1 = entities[1]
entity2 = entities[2]
edges = entity1.all_connected
if (edges)
UI.messagebox edges.to_s
else
UI.messagebox "Failure"
endfaces = []
sel.each do |e| if e.is_a? Sketchup::Face faces.push e end end Sketchup.active_model.start_operation "Wall" faces.each do |e| ent.add_group e e.pushpull (z) end Sketchup.active_model.commit_operation
end
if( not file_loaded?('Wall.rb') )
UI.menu('Plugins').add_item('wall') {wall }
endfile_loaded 'Wall.rb'
I think I have to create a new entety for the faces theat are created to use it in push/pull ?
-
Okay. When it comes to a point and I cannot understand what it is then I move the whole topic to the developers' forum.
Good luck!
-
http://rhin.crai.archi.fr/rld/plugin_details.php?id=250 is the link to midline2wall.rb which looks to be exactly what you want.
-
@sdmitch said:
http://rhin.crai.archi.fr/rld/plugin_details.php?id=250 is the link to midline2wall.rb which looks to be exactly what you want.
Hmmm yes but how can I select multiple lines?
-
Choose the Select tool.
Pick on an object [like a line].
Hold down Ctrl and pick on another object to add it to the selection.
Holding down Shift toggles an object in/out of the selection.
Holding down Shift+Ctrl and picking an object removes it from the selection.With a face one click to pick face, two clicks to pick face and its edges and three clicks to select it AND all other edges and faces connected to it...
-
@tig said:
Choose the Select tool.
Pick on an object [like a line].
Hold down Ctrl and pick on another object to add it to the selection.
Holding down Shift toggles an object in/out of the selection.
Holding down Shift+Ctrl and picking an object removes it from the selection.With a face one click to pick face, two clicks to pick face and its edges and three clicks to select it AND all other edges and faces connected to it...
I was talking about the plugin
-
Why not preselect the lines BEFORE running the tool? Then you process the selection??
You can pick kinds of objects with a Tool using pickhelpers and add them to a 'selection' etc BUT it's pretty complex for a simple tool... -
Can someone explain to me what this lines are for? I know they are for creating faces and offset lines but witch ones do what?
width, height = results
pts = tl[0].vertices
i = 0
pts2 = []pts.each do |pt|
pts2[i] = pt.position + [0 , 0 , results[1]]
i = i +1
end
line_copy = entities.add_line pts2pts_copy = line_copy.vertices
i = 0
j = 0new_face = entities.add_face(pts[0], pts_copy[0], pts_copy[1], pts[1])
new_face.pushpull (width / 2)model.commit_operation
endif( not file_loaded?("zid.rb") )
UI.menu("Plugins").add_item("Zid") { zid }
end
file_loaded("zid.rb")
-
Thomas
You really need to learn to crawl before you walk...
You expect 'random lines of code' to be interpreted for you !
Please structure your questions a little more friendly...width, height = results
presumably this follows a UI.inputbox that results= ?
There were two answers... width & height ??pts = tl[0].vertices
sets an array called 'pts' to be the vertices related to the first element in the array tl - as it's not named logically that couls be a list of faces OR edges...
i = 0
sets a reference called 'i' to be 0 [this is used later in the '.each do' loop ???pts2 = []
Makes an empty array called 'pts2' - presumably this will be filled with elements later...pts.each do |pt| pts2[i] = pt.position + [0 , 0 , results[1]] i = i +1 end
This process the vertices in 'pts' [it would've been better to call it 'verts' ??]
And for each vertex [pt !!!] it returns its position as a 3d-point BUT swaps its z-value for whatever the results[1] was = probably the 'height' so why wasn't 'height' used ??line_copy = entities.add_line pts2
Tis makes a line in [whatever] 'entities' [is] using the array 'pts2' as the 2 points - these have had their z values set to 'height'...pts_copy = line_copy.vertices
This sets the array 'pts_copy' to be the vertices used by the edge 'line_copy' ???i = 0 j = 0
sets the references 'i' and 'j' to 0new_face = entities.add_face(pts[0], pts_copy[0], pts_copy[1], pts[1])
This sets the reference 'new_face' to be the face [if any] that is made using the 4 points listed [if they are not coplanar it will fail!]new_face.pushpull (width / 2)
It pushpulls the 'new_face' by half of the 'width [i.e. results[0] set earlier]
Do NOT leave a gap between the 'pushpull' and its argument in parentheses [i.eface.pushpull(xxx)
NEVERface.pushpull (xxx)
]model.commit_operation end
This closes the 'operation' and 'end's something - presumably the 'def zid
' ?
You must have amodel.start_operation("MyTool")
to 'close' it later...[ruby:1dtqmkst]if( not file_loaded?("zid.rb") )
UI.menu("Plugins").add_item("Zid") { zid }
end
file_loaded("zid.rb")[/ruby:1dtqmkst]
This makes the Plugins menu item a called '[ruby:1dtqmkst]Zid[/ruby:1dtqmkst]' which in turn runs the [ruby:1dtqmkst]def[/ruby:1dtqmkst] called '[ruby:1dtqmkst]zid[/ruby:1dtqmkst]' ???
The [ruby:1dtqmkst]file_loaded[/ruby:1dtqmkst] parts need you to have a [ruby:1dtqmkst]require 'sketchup.rb'[/ruby:1dtqmkst] earlier and ensure that only one menu item appears even if you manually reload the script into the same SKP session...
Advertisement