Oh yeah that's true, Dan.
I missread the codeblock..
Oh yeah that's true, Dan.
I missread the codeblock..
%(#FF0000)[Sketchup.active_model.entities.to_a.each{|e|
if e.get_attribute]
Don't know if there is some speciality in your script, but must not you define |e| ?
Like: if e. is kind of? Sketchup::Someentity OR if e.class Sketchup::SomeentityAnd the put the arguments/conditionals..
Just guessing.. Could be different in your case...
Hey, I missed some posts in here!
Andybot. I'm glad someone have use for this plugin! Appreciate it!(we all know TIG's part of this of course)
AcesHigh.
I've seen your request in other post regarding this subject. Like I said. I think it lies more in the 3d domain, since the surfaces are not flat.
IF the intersecting geometry would be flat at intersectionpoints, 2dBoolean should activate. But I see your case you would need a subtraction-algorythm.
At this point 2dboolean only subtracts geometry outside the face it's lying on(or selected face).
What you are asking for is really needed, and I will see what can be done about that in the future. I'm kinda busy at the moment.
Have to deal with Hatchfaces webdialog, which unfortunaly proves very difficult.
I thought I only had to learn Javascript, HTML, CSS and JQUERY . But there is need for some JSON and maybe AJAX as well. Kinda much required to make a simple dialog if you ask me.
2d boolean only works on "flat" geometry, I'm afraid.
Hint, the name: 2D boolean.
I suspect a terrainmesh is a "3d geometry". Even though it's just a surface you would have to base calculations of 3 dimensions cause of elevations and such.
Maybe you could build a box "underneath" the surface and do standard boolean on that?
A new hatch tool
Ahh, It's for surfaces..
Looks sweet!
Yeah, thanks TIG. All what you say is true.
All these transformations got my head spinning. So I ditched the scaling in the tilingmethod. Went with scaling(y in this case) at ORIGIN, just after loading the component. Before placing it on the face. Not as flexible as in a method, but it will hopefully work. I think Dan suggested something similar, earlier on in this thread.
Maybe that's what you had in mind all along as well, TIG. I just coulden't see it then..
Edit: When I reread you thread, did you mean to scale entities and that would become a "local" scale? Cause i did some scaling in x or y and it was in fact a global scale. The group moved from the face and tilted, even when putting the origin at center of bbox. I can't recall 100% sure if it was the group OR the entities I scaled. Ah heck. I'll try tomorrow then.. Like I said, rather had this transformation separate in the tiling method..
BTW:
This special kind of tiling method will not take any rotation(angle) other than 90.degrees as an argument. The group(hatches) will always have to be perpendicular to the edge.
@unknownuser said:
gt=group.transformation
og=gt.origin
xa=gt.xaxis
ya=gt.yaxis
[za=face.normal
or za=xa.cross(ya)]
Use a rotation transformation about og and za by the angle_between xa and vector ?
Then do a scaling transformation along the xaxis only to match (vector.length / groupX.bounds.width) [where you have used add_instance on group.entities.parent [==definition] temporarily added to the face.parent.entities, at the origin with no further transformation as groupX ?]
Then invert the rotation transformation...
All done ?
Is it that this code is to be used when comp.definition( or group) is at Origin=flat on "ground"?
Cause I get some funky results.. Havent tried "hard" yet. Will elaborate more after lunch....
I've tried something like this where vector is edge:
gt=group.transformation
og=gt.origin
xa=gt.xaxis
ya=gt.yaxis
za=@face.normal #@face=reference to the face.selection
za=xa.cross(ya) #??
x_to_vec=xa.angle_between vector
tr1=Geom;;Transformation.rotation(og, za, x_to_vec)#req. rotation angle
group.transform!(tr1)
ts = Geom;;Transformation.scaling(og, scaling, 1, 1)
group.transform!(ts)
tr=tr1.invert!
group.transform!(tr)
I'm not sure I quite understand where to use you code, TIG. When Importing the component definition?
That could be difficult in this case...
This particular tiling is in it's own method. In the plugin there are other "tiling" methods. So cannot do any altering to the component def. before calling the method of choice. Unless I rewrite the definition loader-method. Could be done of course..
In your code: vector.length / groupX.bounds.width. Is that to determine the scale?
The way this feature will work in the plugin, is that the USER determin number of rows, some code like: edge.length/numbers of rows to determin groupX.bounds.width.
So I'll add that part to your code-snippet?
Edited. Changed some info to clarify things, it's not good to write topics saturday nights :
I think Chris was right about conflicts i vectors(Edge can be perpendicular to 2 axes of course).
So I've scrapped that code..
See if I can incorporate TIG's code, and see if it works. I think I get the idea of it.
Hello TIG. I typed when your answer came in. Bad timing today
Will try your code and report back. Looks interesting.
Thanks a million!!
@unknownuser said:
is returning the vector of the component's local x axis
So it IS the local axis we are dealing with here. Since the scaling is only working on Global axis I persumed it wasen't. Thats good then(hopefully).
@unknownuser said:
You should note that its possible/normal? for 2 vectors to perpendicular to the one you're testing against. So it will scale in 2 directions, not just one
Uh oh That's NOT good! I will do some further testing to se if it fails.
Thanks for all your help.
Ah typical . Too early to celebrate.. It doesent work of axis= face tilted.
Get strange new error no implicit conversion to float from nil
I guess group_x=group.transformation.xaxisis only gonna work if the group is aligned to global axis. Therefore when tilted it has nothing=nil??
Oops. Sorry Dan, must have typed while you post your message.
Your info: Really? Did not have a clue about that. Thats is good news for further developpment. Thank you.
Edit: Think the method works now
Not 100% tested in all angles yet. Changed my code in previous post.
Thanks Dan. Appreciate it.
I have looked at the API. Can't get the comments working so I miss out a few "goodies" there I think..
But as far as I have gotten, scaling Non-uniformly takes 4 arguments. Orgin, scale x, scale y, scale z.
You second advice would have to be plan "B". I have thought of doing something like that, but I'll try to avoid it cause there is plenty of transformations done before the group is even on the face.
I'm working on a method (Cris code gave me an idea)that might possibly work. Just need to retrieve the group local x,z,y axis? If I can.. This is what I have got so far. Could probably use a case method...
You pass in the group, scaling, and vector. Where vector=(edge.start.vector_to(edge.end))
def vec_scale(group, scaling, vector)
#vector need to be parallel or perpendicular or scaling wont work.
##TRANS- and Center####
gents=group.entities
bbox=group.bounds
bbox_c=bbox.center
group_x=group.transformation.xaxis
group_y=group.transformation.yaxis
group_z=group.transformation.zaxis
if group_x.perpendicular? vector
xscale = scaling
else
xscale = 1
end
if group_y.perpendicular? vector
yscale = scaling
else
xscale = 1
end
if group_z.perpendicular? vector
zscale = scaling
else
zscale = 1
end
t = Geom;;Transformation.scaling(bbox_c, xscale, yscale, zscale)
gents.transform_entities(t, gents.to_a)#Normaly you apply t to group. But I need to do it to entities.
end
Hm no. Don't know what I was thinking... Back to square 1.. There are a lot of holes in my method needs filling in.
Need at least to multiply with excisting transformation, as Chris has shown. Will have to take a better look at the second method he provided, or maybe Dan's suggestions if something better don't come up..
Edited: I realize now, what I said about scaling along vector was a bit difficult to understand. I meant scaling along one of the local x,y,z axis IF any of them are perpendicular to the vector(edge).
Ah yes. Why scale along vector? I'll try to explain as good as I can.
There will be an Edge selection on a face that will become the vector(edge.start to edge.end). And the 2d group which scaling will be performed on is glued to the face as well. The scaling will be perpendicular to the edge.
So If the face is "off" Global axis or the 2d group is rotated 90 deg, normal axis scaling won't work.
Will have a look on your new code. Might be a better alternative.
Thanks again.
Hi Chris!
Thank you for the code-snippet. So this is what do you call it, objects "local" scaling?
It might actually work! If doing some tests to see if the "local" x,y,z is on the provided vector direction. The vector will always be perpendicular 90 deg. somehow to the group.
I will do some tests to see if it can be incorporated in my script.
Thank you!
Hi! Getting stuck on something here.
Like the subject says, can one Scale non-uniformly along vector with the standard API methods? Or do one have to go hardcore Matrix or something like that.
I have a 2d group that need some stretching out in 1 direction=vector..
The group doesent really have to be scaled FROM a certain point, it will get translated to place later anyway.
So being 2d-geometry to do a normal uniformal scale, I'll just have to give point3d and a scaling factor for it to work.
That's simple enough but doesen't help me in this case..
API says:
t = Geom::Transformation.scaling point, xscale, yscale, zscale
But, that's fixed on the Global axes while I have an vector + variable for scale factor.
I think I've seen some code for this but forgot where it was.
Would be greatful for help in this, thanks.