Cool! Tried it on FF and worked as advertised.
Posts made by kyyu
-
RE: SCF Forum Syntax Highlighter (v 1.5)
-
RE: [Plugin] Hatchfaces (v1.8 beta) UPDATED 15-Dec-2012
Is that duplicate line needed at line# 136 ?
-
RE: [Plugin] Hatchfaces (v1.8 beta) UPDATED 15-Dec-2012
jolran, looks like you got it working well. So no need to change anything. I will answer the questions, anyways.
@unknownuser said:
Hi Kyyu. Many thanks for your input and experimenting. Really appreciate it
I got a strong impression from reading this forum, that making groupes from selection is a bad choice?
Thats why I neglected my original idea and went for TIG's "face.clone iterating stuff". Don't you get splats doing it like that? Have you tried this inside a group? I got constant splats doing almost exactly as you did.However grouping the edges before doing an intersect_with might be a good idea. That might actually be an easier method than iteration the edges for erasing? Depends on how "splat-prone" the method is.
Yes, it's to be avoided. But you can do it, under certain circumstances. Grouping loose geometry is ok, especially a single edge or face. In my example, I grouped a face at the very beginning. And it do it, just once. I've written plugins, like this, before. You can't do it what an entitiy, already inside a group. I'm assuming it has to be in the current active_entities.
If, I am just testing a quick snippet of code, I certainly will just group the face instead of writing a bunch of lines to clone it.
You only need to consider doing all this, if you didn't make the entitiy. If you want your lines in a group, then you would make an empty group 1st, and then create the lines directly in the group (gents.add_line instead of ents.add_line).
@unknownuser said:
About separating to 3 groups. Don't know if that is necessary? Doesent it suffice to add the hatches to a new layer? (Which is already implemented in my current code). This grouping In my opinion does no good for the workflow. Need more feedback about that, please
It all depends on how you are doing stuff. My thoughts on 3 groups is as follows: Group1 is your cloned face group. If you decide to group your line pattern, then that's group2. When you use intersec_with, you can choose where the new lines go. You can't put them in group1 or group2. They would merge and you have to clean them up. So you put them in group3. Then you only need to delete group1 & group2. No need to find and delete any edges. That's what my example does. Except, I just explode group1, becasue I don't make a clone.
@unknownuser said:
I'm using AS ruby code editor. It's the same as Jim's no?
Should be the same. Just suggesting an editor that can execute the code, if you aren't using one. I use Notepad++ for that and reload using Jim's Ruby Toolbar. But Jim's Ruby Web Console does the undo automatically. And very easy to test small bits of code. I still use his older version.
-Kwok
-
RE: [Plugin] Hatchfaces (v1.8 beta) UPDATED 15-Dec-2012
Sorry, disregard, was trying to edit the previous post.
-
RE: Intersecting 2 Groups Question
Thanks, TIG. Lots of times, a beginner is not cofident enough to jump in there and make too many comments, even on this forum. Did you still need a google account, to post that anonymous comment in the API?
-
RE: [concept] plugin launcher
You are confusing loading and running. Once you have the plugin loaded, then you have access to his functions in the menu and/or toolbar. The toolbar could be hidden, so that will add another step. Jim's toolbar plugin is an alternate toolbar. So it would need to know and mimic the particular calls/commands.
-
RE: [Plugin] Hatchfaces (v1.8 beta) UPDATED 15-Dec-2012
jolran, a few suggests for you to consider.
-
Seperate out the code that draws the line pattern, into it's own method. That will make your main program simpler to understand. It will look more like an outline. Check out my later example code snippet. I just premade the line pattern, by hand, which would represent simply calling a method to make it. Also, you can reuse the draw_lines method, say if you want to draw a 2nd set in the criss cross direction.
-
Might want to consider a rethink. The program will become more complicated, if you just keep adding stuff on top of exsiting. Here's a possible new way, shown below. And the way I test stuff quickly, is to use the "Ruby Web Console" plugin by Jim Foltz. I often check parts of my program, like this, as snippets of code; before adding it to the plugin. You simply undo <ctrl+z>, change the line(s) of code and execute the code again, by hitting the "eval button".
#This snippet puts the face,lines & hatch into 3 seperate groups. Face is simply grouped, not copied. #The "lines" group is premade and named "lines", so the script can find it. #You need to select the face, before running script #No need to delete seperate edges, just delete the lines group when done. model = Sketchup.active_model ent = model.entities sel = model.selection f = sel[0] face = ent.add_group(f) lines = (ent.to_a.select {|e| e.is_a?(Sketchup;;Group) and e.name=="lines"})[0] puts lines hatch = ent.add_group hent=hatch.entities; lent=lines.entities; fent=face.entities htr=hatch.transformation; ltr=lines.transformation; ftr=face.transformation fent.intersect_with(true, ftr, hent, htr, false, lines) lines.erase! face.explode
![After pressing "eval" button](/uploads/imported_attachments/Hdko_test_hatch_rwc_after.png "After pressing "eval" button")
test_hatch_RubyWebConsole.skp -
-
RE: Intersecting 2 Groups Question
@tig said:
So you are saying that
entities.intersect_with()
return the geometry that's added ?
I have tested this and I can confirm that you are correct -geo=entities.intersect_with(.....)
will return an array 'geo' of any newly made geometry - in direct contravention of what the API notes say !
Have you posted a comment in the API section ?No I haven't posted a comment. I am a beginner, found the docs very confusing at the beginning and don't take them literally. In the past, I've had to test stuff to see what they actually do. Plus I sometimes figure(or partly figure) out something, then forget it and later have to relearn it. On top of that, I don't have a google account. I may be force to get one someday, but I don't like them trying to link to my youtube account. And some lame stuff they did, when I had google video. If I went and posted "It doesn't always return 'nil'", don't think that would be very useful.
But I can show proof, with an example. You can use that test file I posted above and move the face group up onto the lines group. Then run this script. In the picture, I've selected the 37 edges that were created. You can see in the ruby console, an array was returned with 37 edges.
model = Sketchup.active_model ent = model.entities sel = model.selection face = (ent.to_a.select {|e| e.is_a? Sketchup;;Group and e.name=="face"})[0] lines = (ent.to_a.select {|e| e.is_a? Sketchup;;Group and e.name=="lines"})[0] puts face; puts lines lent = lines.entities fent = face.entities tr = Geom;;Transformation.new ltr = lines.transformation ftr = face.transformation int = fent.intersect_with(true, ftr, ent, tr, false, lines) puts int puts int.class puts int.length
-
RE: Intersecting 2 Groups Question
@tig said:
http://code.google.com/apis/sketchup/docs/ourdoc/entities.html#intersect_with says 'intersect_with' returns 'nil' always...
And we all know the are no mistakes in the API docs. But seriously, I know in practice that it's not true. I have a plugin that slices up a solid and add the edges returned each time, into an array. Looks something like this:
while @x < @total int = intersect_with_plane(plane) int.each do |i| @@cary << i end @x += @inc move_plane(plane, @inc) end def intersect_with_plane(plane) t = Geom;;Transformation.new int = @@plane_ent.intersect_with(true, plane.transformation, @@ent, t, false, @@g) end
-
RE: Intersecting 2 Groups Question
@tig said:
Try
ent.intersect_with(true, tr, ent, tr, false, [face,lines])
You do realize that the resulting geometry goes directly into the model's active_entities?
Why no put that into a group - at least initially?
Note, since it always returns 'nil' there's no point in assigning a reference to this operation with int=...Thanks, TIG. I haven't thought of it that way before, when trying to intersect two groups. That way worked. I used "intersect_with" with several past plugins, but still trying to understand it fully. Just doing some basic testing of general cases. So it doesn't matter, if the geomtry is simply going into the models's active_entities.
It doesn't always return 'nil'. Your way returns the new edges. That paticular case I was asking about returns 'nil'. And didn't work, in certian situations, like I expected. But using face.entities as reciever also returns the new edges, and works exactly the way I expect. The only difference I can see is possibly face.entities has a face in there, whereas lines.entities doesn't? Using lines.entities as reciever seems to returns 'nil'.
-Kwok
-
Intersecting 2 Groups Question
Hi, need some help figuring something out. I would like to intersect a set of lines with a face. The face is grouped. I can do it with the lines as loose geometry, as you see it set up in the picture.
int = ent.intersect_with(true, tr, ent, tr, false, face)
But if I move the face up to the grouped lines, I can't get it to work with this new line. I am changing it to use the line group entities, instead of the model's entities:
int = lent.intersect_with(true, ltr, ent, tr, false, face)
Any idea how to get this to work?ent = Sketchup.active_model.entities face = (ent.to_a.select {|e| e.is_a? Sketchup;;Group and e.name=="face"})[0] lines = (ent.to_a.select {|e| e.is_a? Sketchup;;Group and e.name=="lines"})[0] puts face; puts lines lent = lines.entities tr = Geom;;Transformation.new ltr = lines.transformation int = ent.intersect_with(true, tr, ent, tr, false, face)
-
RE: [Plugin] TT_Lib²
@roger said:
ThomThom I am running 8 Pro and am trying to install "solid inspector." I have TT_Lib2 installed in the plugins folder and "tt_solid_inspector" installed in the "plug ins" folder.
When I start 8 I can not find any indciation of the programs existence. Any ieas of where I can begin looking for the problem?
Thanks.
It saids the following, in the description. Did you check there?
@unknownuser said:
Access
Tools > Solid Inspector -
RE: [Plugin] Hatchfaces (v1.8 beta) UPDATED 15-Dec-2012
@jolran said:
Guys, I'm glad youre showing interrest in this plugin! I will try to do by best to improve it.
About Autocad compability.. You have to realize, 2 months ago I had no programming experience att all and
that feature sounds fairly complex. I think priority must be made to get spacing OK, and holes get filled.You're doing good for 2 months. I started the same way, with no programming experience, about 1 & half years now. I still have alot to learn. Takes alot of time at our level, to do even simple stuff.
@unknownuser said:
@unknownuser said:
file_loaded("Hatchfaces.rb")
Hmmm, thought I did not need that. It's not loading right for you?
Concerning this line of code. It put's your plugin in a list of loaded files. That's the list your are checking when you say "unless file_loaded?("Hatchfaces.rb")". So if you don't have the loaded line, then there is no reason to check if the file has been loaded in the 1st place.
I thought Sketchup would give me a 2nd toolbar, if I loaded the plugin again. But it appears not. Maybe Sketchup won't let you have two toolbars with the same name? So I guess it didn't matter,after all, for your plugin. But, like I mentioned, then you could have left out the 1st line, also. Where it matters, is menu items. Sketchup will add a new menu item each time you reload a plugin, if you don't have those 2 lines.
And as a fyi, these two methods are in the "sketchup.rb" file. That's probably why you have the line at the very beginning: "require 'sketchup.rb'"
-Kwok
-
RE: [Plugin] Hatchfaces (v1.8 beta) UPDATED 15-Dec-2012
jolran,
To get the spacing right; make the 3 changes in red:
@unknownuser said:
vp=ve.transform(tr) vp.length=di*2
vs=face.normal.cross(vp) #spacing vector perpendicular to hatch line
tot=0
until tot>=di*2
ps=pt.offset(vp)
pe=pt.offset(vp.reverse)
gents.add_line(ps,pe)
pt.offset!(vs,spacing)
ps=po.offset(vp)
pe=po.offset(vp.reverse)
gents.add_line(ps,pe)
po.offset!(vs.reverse,spacing)
tot=tot+spacing
end#untilI think you are also missing this line at the end:
@unknownuser said:
unless file_loaded?("Hatchfaces.rb")
toolbar = UI::Toolbar.new("Hatchfaces")
cmd0 = UI::Command.new("Hatchfaces") { self.hatchfaces }
jol_icons = Sketchup.find_support_file "Plugins/Hatchfaces/hatchfaces_s.png"
jol_iconl = Sketchup.find_support_file "Plugins/Hatchfaces/hatchfaces_l.png"cmd0.small_icon = jol_icons
cmd0.large_icon = jol_iconl
cmd0.tooltip = "hatched lines"
cmd0.status_bar_text = "faces to hatch selection"
cmd0.menu_text = "Hatching"
toolbar.add_item cmd0
toolbar.showend
file_loaded("Hatchfaces.rb")
end
-
RE: [Plugin] Caleidos4D Ribbon Pubblic Beta 1.1 (29 oct 2010)
Caleidos4D,
Thanks for the plugin. Looks interesting. Got a question. When you select the major frames on the left side (Costruction[oops,btw spelling error], Projection, 2D, Modelurs,..etc), they change to a highlighted orange color. But when you select another, any previous ones are still hightlighted orange. Wondering if this is a bug?
Oh, and an off topic question. Is there a easy html editor for laying out buttons, like this, on a webpage? Or wondering what editor, you used? I mean, if a beginner wanted to make the html portion of a web UI, like this. I can make a simple one by hand, like a column of buttons, but not like this.
-Kwok
-
RE: Plugin problem in SU8
ktkoh,
I got the same thing you described. Worked fine in SU7, but bugsplat when starting with a space in SU8. Will let you know, if I figure anything out.
-
RE: {REQ} Perimeter Trace?
Here is a quick snippet of code. To run it type "ky_shell_bottom" in the ruby console. If you want only the perimeter edges, then uncomment the few lines of code at the end.
test_shell bottom.skp
ky_shell_bottom_snippit.rb -
RE: [Plugin] RandomPushPull v2.5 20110709
@tig said:
As I explained, the original face is lost with a pushpull so I need to find the equivalent new face... At the moment it matches area, face normal and face plane [offset by the pushpull distance] - even the slightest variance in the figures that Sketchup calculates will result in a mismatch - so I suspect that's why some faces are being ignored
Any ideas on a better way to spot newly pushpulled faces is invited...TIG,
Seems to work 100%, if you account for the tiny area difference of the new face. In line #64, I used "if face.area-e[0].abs < 0.000001" instead of "if face.area==e[0]".
Well, at least this worked on a 7 inch diameter sphere. Don't know if it will fail for other scales.
[Addition]
Ok, I had a chance to check if scaling would make the new area test fail. Looks ok so far. My sphere had 288 faces. Initially 7 inches in diameter. I've scaled it up to 70, 700, and 7000 inch diameter. And even with the larger areas, 0.000001 difference still worked to compare if the faces have the same area. The plugin still kept the selection on all 288 faces, in all the tests. -
RE: Get rotation(transformation)
@jolran said:
...Except that the "bug" is that the translation distance doesent get 100% accurate if the face is very distorted.
Maybe that is what you are trying to fix, and I don't see it.
If thats the case sorry I'm a noob, you know.Yes, that is what I am showing how to fix.
-
RE: Get rotation(transformation)
@jolran said:
Hi Kyyu!
Interresting. So you mean I use the 3rd vector for measuring? Or was it meant to be
a method to get an angle 45 deg of the vector?
Remember 45 deg is just an example for this particular hatching. The user must be able to
choose any angle for the lines across the face.I will look into it more and see if I understand you code a little better.
Thank you Kyyu.The 3rd vector would be your translation vector. In your code you have it as:
vector=diag_vect vector.length= user_length
It's perpendicular to what ever your final line is. Here, I just changed the line to a random new angle, not 45 deg. I set the length of the vector (distance of translation) to 1.