How do you calculate area of a face inside a scaled comp?
-
As I recall, it's a very complex procedure involving a lot of trigonometry, intense calculations, and sacrificing a chicken at solstice (for SU4-6; for SU7+, it's at equinox).
-
So complex that SU gives you two different numbers..? Doesn't sound promising?
Maybe a bigger chicken will work? Or could penguins be a better solution? -
Can't get it from the component's definition? I don't think a def has a transformation.
-
The Component Definition would be no good. I need to get the size of the scaled Component Instance.
Basically, I'm making a script that calculates the total area to which an material is applied to. But since groups and components might be scaled I need to calculate the end result with the scaling taken into account.
-
I checked the face.plane for the object, and it reports the plane as still being at a 30 degree angle, with an area just under 10,000 units. I can approximate the actual area by dividing the reported area by Math.cos(30.degrees) and multiplying the result by 1.3 (the other scale factor), but that's not close enough. Still working...
-
Okay, for your specific example:
The face was drawn at an angle, so get the plane info.
face.plane will yield a throwaway (in this case), the sin, and the cos values.
You want to multiply the sin by the z scale factor (1.6 in this case) to find the new height of the top edge. Once you have the new height, get the hypotenuse of the cos and the height. Multiply all that by the other scale factor and the original area.t = group.transformation.to_a area = face.area*Math.hypot(Math.cos(30.degrees),Math.sin(30.degrees)*t[10])*t[0]
Keep in mind, rotating the g/c or changing the y scale factor will affect things similarly, and you'll have to take that into account and modify your calcs accordingly. But I hope that can get you started.
No chickens were harmed in the creation of this code snippet (though one did find its way into my lunch a little while ago).
-
While no chickens where harmed, my brain is suffering.
Thank you very much for looking into this Rick. But I think I need to do some more reading up on trigonometry so I can understand the math here. I will need to take into account scaling in all direction and possible rotation. Can anyone recommend a good resource for this? Preferable something where the description is accompanied with illustrations.
-
Hey Thom, while searching around for something else, I came across an old thread that also dealt with this. There were apparently some good ideas and I think AdamB at the end posted a final solution. You might check it out if you need still,
http://www.sketchucation.com/forums/scf/viewtopic.php?f=180&t=11258
Chris
-
Chris! I think you just saved my brain from terminal meltdown!
-
Oh good, glad I could be of help....even though I didn't provide any technical expertise
Chris
-
Thomas,
A workaround.....- Copy all geometry of interest to a new file.
- Explode all of interest or a selection - this gets around your components problem (bomb.rb may be useful here ???).
- Didier has a really good script - quick_selection.rb (?). This allows you to select (for example) only faces (not edges), or combinations eg faces on a certain layer or with a certain material.
- Once selection is made - entity info will give you the combined area of all selected faces.
...........
Hope this helps
Howard L'
-
Hi Howie. The thing is though, it's for a script I'm making, so I would need to work this out in Ruby. Thanks though.
-
@thomthom said:
Hi Howie. The thing is though, it's for a script I'm making, so I would need to work this out in Ruby. Thanks though.
Under ruby control, you could do a start_operation, explode the component, take your measurements, then commit_operation, then undo. CB.
Advertisement