VBA - Creating Lofts with Lots of Rails

VBA - Creating Lofts with Lots of Rails

demuff
Enthusiast Enthusiast
687 Views
4 Replies
Message 1 of 5

VBA - Creating Lofts with Lots of Rails

demuff
Enthusiast
Enthusiast

Hi all,

 

I've got an algorithm working that generates sketch profiles so that will ultimately be used in a loft. Each loft section is a closed spline made up of the same number of points, but the number of points can be varied at the start of the algorithm to increase of decrease the resolution. I was hoping to simply supply the loft profiles and have Inventor loft correctly between them, but it looks like that's not going to happen.

 

So now I'm left with rails. I would like to supply a rail between every corresponding point throughout my profiles. The documentation is frustratingly sparse on this topic, but what I've gathered from some other forum posts is that every rail needs to be created in its own sketch. In my algorithm I can generate all of the rails easily, but for profiles that may contain hundreds of points it will quickly get out of hand to create so many sketches for individual rails just to apply them to the loft.

 

Is this the only way? From the UI loft dialog multiple rails can be set from the same 3D sketch, so I would presume there is some way of doing it with VBA. I've considered only applying rails to some fraction of the points, but due to the rate at which the profiles may change between sections it would be far preferable to be able to constrain every point with its own rail.

 

Below is an example of the kind of profiles I'm looking to loft together. Thanks!

profiles.PNG

 

 

 

0 Likes
688 Views
4 Replies
Replies (4)
Message 2 of 5

wayne.brill
Collaborator
Collaborator

Hi,

 

I discussed your questions with a colleague and he suggested you shouldn’t need the rails because it will essentially be the same result with or without rails with the approach your taking. However I could try this to be sure.

 

It also looks like a major portion of each section is part of an arc.  It maybe be better to create two bodies, a cylinder and the complex shape at the top, and then cut the complex body from the cylinder to create the final shape.

 

If you upload something to test this with I will research it.

 

Thanks,

Wayne



Wayne Brill
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 5

demuff
Enthusiast
Enthusiast

Thanks, Wayne.

 

It would indeed be ideal to not use rails at all. This was my first try, but the loft would almost always fail with just the profiles as inputs. Providing a centerline fixed a couple of simpler cases, but a majority still couldn't compute the loft. Manually adding rails successfully created every loft I tried, but as I mentioned earlier it will get tedious for a large number of boundary points and profiles.

 

You are correct that a large portion of the sample image is composed of a constant radius arc. However this is a specified constraint to limit the radial boundary of the profile. For the general case the generated profiles will be completely irregular based on the assembly geometry being analyzed so I won't be able to divide the solid into sub-shapes.

 

I've attached some parts that demonstrate what's going on, however there is another problem:

 

LoftPoints_Broken.ipt is the direct output from my script. The part is created inside an assembly and edited in place to add the loft points from the cut profiles of solid bodies in the assembly environment. I can continue to edit the part in context but as soon as I try to save the part independently I get invalid segment reference errors like this, which totally breaks the part. The definitions of the planes appear to be the problem, but I don't know what causes this error or how to correct it so if you have any thoughts they would be much appreciated.

 

LoftPoints_Derived.ipt is just the sketches derived from the first part to get around the errors. If you look at this part you'll see that trying to loft all the profiles together at once with no rails/centerline will not compute.

 

Hopefully there is something that can be done for both issues. Thanks!

0 Likes
Message 4 of 5

wayne.brill
Collaborator
Collaborator

Hi,

 

I find I am manually able to create the loft using the 5 profiles. (screenshot below). Please let me know which version of Inventor you are using.

 

I see that ticket 69945 is still under investigation. Any chance you could provide an assembly and code I could use to recreate a corrupt ipt like LoftPoints_Broken.ipt?

 

 

 

Loft_Completed_WB.jpg

 

Thanks,

Wayne



Wayne Brill
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 5 of 5

demuff
Enthusiast
Enthusiast

Interesting...we were actually just upgraded from 2014 to 2016 yesterday and I'm now able to generate the loft for the part that I posted. I've still had it fail for a couple more intricate profiles even on 2016 but it looks like the code has gotten more robust. I would still like to find a better way to use a lot of rails if only to better control the loft shape but it sounds like there aren't a whole lot of options beyond what I've already tried.

 

I can't post my code, but I was actually able to resolve the problem. I was correct in my initial observation that the generated planes were somehow the problem. I was able to trace the error back to a the line where I define the current plane of the profile. I was using 

.ComponentDefinition.WorkPlanes.AddByPlaneAndOffset(...)

in a loop to define each plane. However, because I was editing the part in place, my Plane argument to the AddByPlaneAndOffset command was an assembly plane. Therefore I was able to modify the part freely in place in the same instance of the assembly, but as soon as I closed the assembly or saved the file elsewhere that relationship didn't transfer and I received that error.

 

I corrected this by defining the first plane with

.ComponentDefinition.WorkPlanes.AddFixed(...)

 and subsequent planes using the AddByPlaneAndOffset from the fixed plane.

 

I imagine you could duplicate this issue by doing exactly what I've described above during an in place edit.

 

Thanks for working with me on this. If there's any additional information I can provide to assist in resolution of this error let me know.

0 Likes