Moved from the general discussion forum..
----------------------
I have an issue with the Sketch3d.Profiles.AddOpen() and the LoftDefinition.Rails.Add() api.
In the example below, I have generated thee sketches: 1,2 and 6. 1 and 2 contains the start and end profiles, while sketch6 contains four splines. However, when I call Profiles.AddOpen(), only one profile is created for sketch6, and when the Loft is built, only one rail is included... Any ideas as to why? I've only got twelve sketchpoints, that is, sketch6 uses the same sketchpoints as 1 and 2... Can this be an issue?
I'm using Inventor 2016, and Visual Studio C#.
Hello,
did you realise this work only in Inventor without API to confirm that you can do it ?
Nope 🙂
I use it to create automated parts with complex geometries which cannot easily be implemented by ordinary means (I develop products where fluid dynamics dictate the shape).
I had to change my fundamental approach in this case. As for status, I now have a flexible and parameterized part which can be customized to the customers need and easily be produced through CNC machining. So, yes, this definitly gives us an edge, compared to the competition.
Arne
Ah... I see the question was a bit different than what I thought.
Well, the case above is created by API only. I verified that it was possible to do manually, but I couldn't figure out how to do it through the API. The .AddOpen api only returns the first profile, where it should have returned all.
Arne
I dont know much about the whole picture of you code, but normally you have to create sketch entities and than create the profile, who picks all entities already created (since you cant pass a collection as parameter to the function).
So you have to do it as many times as you need profile to create the feature.
In your case its 2 times I guess.
And it should be fine.
Here is an exemple of code, that I completed for someone else, which create lines and than use it to do a Loft feature :
Sub loft() 'Declare PartDocument to activate Intellisense Dim oDoc As PartDocument Set oDoc = ThisApplication.Documents.Add(kPartDocumentObject, , True) Set oPartDef = oDoc.ComponentDefinition Dim osketch3D As Sketch3D Set osketch3D = oPartDef.Sketches3D.Add() Set oTG = ThisApplication.TransientGeometry Dim wire(198) As SketchLine3D Set wire(0) = osketch3D.SketchLines3D().AddByTwoPoints(oTG.CreatePoint(0, 0, 0), oTG.CreatePoint(10, 0, 0)) Set wire(1) = osketch3D.SketchLines3D().AddByTwoPoints(oTG.CreatePoint(10, 0, 0), oTG.CreatePoint(10, 10, 1)) Set wire(2) = osketch3D.SketchLines3D().AddByTwoPoints(oTG.CreatePoint(10, 10, 1), oTG.CreatePoint(0, 10, 0)) Set wire(3) = osketch3D.SketchLines3D().AddByTwoPoints(oTG.CreatePoint(0, 10, 0), oTG.CreatePoint(0, 0, 0)) 'Declare Profile3D to regroup wires. Dim oProfile1 As Profile3D Set oProfile1 = osketch3D.Profiles3D.AddOpen 'Declare another sketch to be able to catch 2 differents profiles. Dim osketch3D2 As Sketch3D Set osketch3D2 = oPartDef.Sketches3D.Add() Set wire(4) = osketch3D2.SketchLines3D().AddByTwoPoints(oTG.CreatePoint(0, 0, 5), oTG.CreatePoint(10, 0, 5)) Set wire(5) = osketch3D2.SketchLines3D().AddByTwoPoints(oTG.CreatePoint(10, 0, 5), oTG.CreatePoint(10, 10, 5)) Set wire(6) = osketch3D2.SketchLines3D().AddByTwoPoints(oTG.CreatePoint(10, 10, 5), oTG.CreatePoint(0, 10, 5)) Set wire(7) = osketch3D2.SketchLines3D().AddByTwoPoints(oTG.CreatePoint(0, 10, 5), oTG.CreatePoint(0, 0, 5)) 'Declare second Profile3D to regroup wires. Dim oProfile2 As Profile3D Set oProfile2 = osketch3D2.Profiles3D.AddOpen 'Create object collection need by Inventor functions. Dim oCollection As ObjectCollection Set oCollection = ThisApplication.TransientObjects.CreateObjectCollection 'Add profiles to collection. oCollection.Add oProfile1 oCollection.Add oProfile2 'Create loft definition needed by Loft function. Dim oLoftDef As LoftDefinition Set oLoftDef = oDoc.ComponentDefinition.Features.LoftFeatures.CreateLoftDefinition(oCollection, kSurfaceOperation) 'Creating loft. Dim oLoftFeat As LoftFeature Set oLoftFeat = oDoc.ComponentDefinition.Features.LoftFeatures.Add(oLoftDef) End Sub
I hopes its gonna help you.
J-S