I am currently trying to recreate an object that is essentially a 3D-histogram. This involves importing the point cloud (x,y,z) and using addByCenterRectangle to create rectangle sketches 3mm x 3mm on the XY plane. I then use the z-value in the point cloud to determine the extrusion distance, and then extrude. Here is an example of my "finished" product:
Now the problem is, when I create the sketches without the extrusions, they appear to be positioned as expected, as seen by the following example of just a few iterations of the loop (960 in total, so takes a long time):
However, when I access the profile of the sketch within each loop using sketch.profiles.item(sketch.profiles.count-1), the areaProperties.centroid are positioned absolutely incorrectly. Below is a graph showing the actual XY positions of each sketch and on top of them are the positions of the profiles. The total number of profiles is correct, just that they are duplicated.
So when I extrude using the latest profile in each loop, I get multiple extrusions in the same location, and not matching the original point cloud locations nor the original sketch locations.
Now, my "solution" to this was to make each rectangle slightly smaller (2.90mm instead of 3.0mm) so that the boundaries of each sketch do not overlap. This results in the correct placement of the sketches/profiles/extrusions, however with visible gaps in between each extrusion, which I do not want (looks bad when rendering).
I would like them to be next to each other and would result in a continuous shape with no gaps as if all the extrusions were apart of the same body. Do I have to add some contstraints to resolve these apparent boundary problems? If so, how?
Attached is an example .py file with example XYZ .csv files.
Thanks
Solved! Go to Solution.
Solved by ekinsb. Go to Solution.
There are a few things you can do to simplify and improve the performance of your program. First, getting the last profile in the collection of profiles will not work. The profiles in the collection should not be assumed to be in any order. Instead you need to look through all of the profiles and find the one that represents the position you want to create the extrusion for.
There are a couple of things you can change that I think will improve the performance. First, is to run the program without capturing the design history. You change that in the UI using the option shown below. This should speed up the processing significantly.
The second thing is how you're creating the sketch. There are two different approaches you can take here. One is to construct the entire grid of squares using a series of paralllel horizontal and vertical lines. You'll have less sketch geometry and the profile geometry will only be computed a single time. Fusion calculates profiles where curves overlap so it's not necessary to create four seperate lines for each square. Once you've created this sketch you'll need to analyze and sort the resulting profiles to figure out which one is which so you know how far to extrude it. You can use the area properties that you're already using.
Another approach is to create a new sketch for each block. This way there is only one profile and you won't have to do the extra work to figure that out. There will be more geometry created but the program will be simpler. In a direct model, the feature doesn't remember the sketch that was used to create it so you can even delete the sketch or its contents before moving onto the next extrude. It will take a bit of trial and error to see which approach is the fastest.
Thanks heaps, ekinsb. I cannot believe how much faster it is without it keeping the history! Crazy!
Sketching just the necessary lines and then going through each profile and matching its centroid to the correct point proved an excellent way of doing it.
Just one more question, is there a way to make all these extrusions part of the same body / join them so they don't have their outlines seperating them?
Thanks again!