Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Sketch locations and sketch profiles not matching up

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
lc752
566 Views, 4 Replies

Sketch locations and sketch profiles not matching up

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:

 

bolus.PNG

 

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):

 

bolus_2.PNG

 

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. 

 

Centroid.jpg

 

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

4 REPLIES 4
Message 2 of 5
ekinsb
in reply to: lc752

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.

 

DesignHistory.png

 

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.

 

LineGrid.png

 

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.

 


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 3 of 5
lc752
in reply to: ekinsb

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!

Message 4 of 5
lc752
in reply to: lc752

In case anyone reads this, this page helped with my final question.

Message 5 of 5
gscotti
in reply to: ekinsb

Can you disable timeline capture programatically?

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report