Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Create Path for Sweep

10 REPLIES 10
Reply
Message 1 of 11
Anonymous
1259 Views, 10 Replies

Create Path for Sweep

Not able to create path for sweep. Input Polyline3d represents a rectangle in a planar sketch. Now wish to create path line normal to rectangle at one of the points. Note: "m_thickness" is some double value.

 

Private Function CreatePathForFlange(ByVal oPl As Inventor.Polyline3d) As Inventor.Path

    Dim point1 As Point = oPl.PointAtIndex(1)
    Dim point2 As Point = oPl.PointAtIndex(2)
    Dim point3 As Point = oPl.PointAtIndex(3)
    Dim point4 As Point = oPl.PointAtIndex(4)

 

    Dim v1 As Vector = _invApp.TransientGeometry.CreateVector(point2.X - point1.X, point2.Y - point1.Y, point2.Z - point1.Z)
    Dim uv1 As UnitVector = v1.AsUnitVector

    Dim v2 As Vector = _invApp.TransientGeometry.CreateVector(point4.X - point1.X, point4.Y - point1.Y, point4.Z - point1.Z)
    Dim uv2 As UnitVector = v2.AsUnitVector

    Dim v3 As Vector = v1.CrossProduct(v2)
    Dim uv3 As UnitVector = v3.AsUnitVector
    uv3.AsVector.ScaleBy(m_thickness)
    Dim point5 As Point = point1.Copy()
    point5.TranslateBy(uv3.AsVector)

 

    Dim wpt1 As WorkPoint = m_compDef.WorkPoints.AddFixed(point1)
    Dim wpt2 As WorkPoint = m_compDef.WorkPoints.AddFixed(point5)

 

    Dim pl As WorkPlane = m_compDef.WorkPlanes.AddFixed(point1, uv1, uv3)


    Dim skt As PlanarSketch = m_compDef.Sketches.Add(pl)


    Dim skpt1 As SketchPoint = skt.AddByProjectingEntity(wpt1)
    Dim skpt2 As SketchPoint = skt.AddByProjectingEntity(wpt2)


    Dim skln1 As SketchLine = skt.SketchLines.AddByTwoPoints(skpt1, skpt2)

 

    Dim oPath As Inventor.Path = m_compDef.Features.CreatePath(skln1) '*************ERROR

    CreatePathForFlange = oPath

 

End Function

 

Anything missing?

Tags (1)
10 REPLIES 10
Message 2 of 11
Balaji_Ram
in reply to: Anonymous

Hi Yogesh,

 

The Features.CreatePath would require a SketchLines3D or any of the other 3D sketch curves.

Please try the following :

 

1) creating a 3D sketch (ComponentDefinition.Sketches3D.Add)

 

2) create a the path curve using the SketchLines3D / SketchArcs3D etc.

 

3) oCompDef.Features.CreatePath and pass in a SketchLine3D

 

4) Create a profile out of the sketch

 

5) Create the sweep using SweepFeatures.AddUsingPath

 

In the Inventor API help you should look at "Sweep Feature Add API Sample" for an example

 

Regards,

Balaji



Balaji
Developer Technical Services
Autodesk Developer Network

Message 3 of 11
Anonymous
in reply to: Balaji_Ram

Followed the suggested procedure, but the path probably was not good. Could not create SWEEP. Attached the path error.

Message 4 of 11
Balaji_Ram
in reply to: Anonymous

Please try the lab-4 from this tutorial sample projects.

 

That should help understand the procedure and you can then modify it to suit your needs.

 

http://modthemachine.typepad.com/my_weblog/2012/02/inventor-api-labs-step-by-step.html

 

Regards,

Balaji



Balaji
Developer Technical Services
Autodesk Developer Network

Message 5 of 11
Anonymous
in reply to: Balaji_Ram

Let me say few words about what I am doing. My task is to represent sheet metal features like FACE, FLANGE etc to equivalent EXTRUDE/REVOLVE/SWEEP feature representation => CreateCorrespondingABELFeature().

 

Here 'ABEL' means EXTRUDE/REVOLVE/SWEEP.

 

E.g. 'FACE' feature has a profile. I can use this profile to create a new sketch, then using sheet metal thickness property, create a new EXTRUDE. It will 

have same geometry/shape as that of original FACE, only the feature would be EXTRUDE.

 

Similarly I am trying to create equivalent SWEEP of a FLANGE feature.

 

Steps I am following are:
- I find smaller face connected to flang's input edge.
- extract boundary of that face as polyline3d => ExtractBoundaryOfFace()
- create a new sketch and create a new profile in it by projecting polyline3d => CreateSketchOutOfFaceBoundary()
- create a new plane, perpendicular to the face, for creating sketch for SWEEP path => CreatePathForFlange()
- create a sketch3d line in the sketch as path.
- using profile sketch and path sketch create SWEEP equivalent to the given Flange => CreateNewSweep()

 

Input part is MyProject/SheetMetal_Simple_Uclip.ipt

 

Code is at https://drive.google.com/open?id=0B9ZSXyeZHd37T0pOcmJHbk9LaHM&authuser=0


Once you run the project, small button will come, after pressing it, you should start seeing new ABEL features getting created.

Please let me know if you are able to build, run and see the problem. (Note: you may want to change reference to your Inventor API dll.)

 

Message 6 of 11
Balaji_Ram
in reply to: Anonymous

Sounds like quite an involved task.

 

You may need to consider several settings of the default sheetmetal rule to generate the correct profile to sweep if the end result of the sweep has to match the flange feature.

 

For a simple flange that i created, the profile generation was completely off and resulted in a sweep error.

My suggestion would be to just let you code generate the sketch and the sweep path and not do the sweep.

After that manually try sweeping it using Inventor UI to generate the sweep. That way you will have more data to analyze where you are going wrong.

 

I have attached the screenshot for a simple flange feature and the sample project that you shared was completely off in generating the sweep profile needed to reproduce the flange feature. 

 

Regards,

Balaji



Balaji
Developer Technical Services
Autodesk Developer Network

Message 7 of 11
Anonymous
in reply to: Balaji_Ram

Yes, its very hard to know how much the FLANGE has gone inside even after picking an edge from previous FACE feature.

For now, I am allowing this error. Meaning even if the sketch and the path are bit off (as shown with dark purple in your picture), I am ok.

 

But still I am not able to create SWEEP with the nenerated sketch-path programmatically. I can select them and create proper SWEEP interactively. So, for now, can you guide in creating SWEEP with the dark purple sketch and linear path attached to one end?

Message 8 of 11
Balaji_Ram
in reply to: Anonymous

Can you try changing the part feature operation enum to kJoinOperation. That succeeds in creating the sweep

and it should not affect the end result as the sweep feature does not intersect any of the other features.

 

SweepFeatures.AddUsingPath(oProfileOne, oPath, PartFeatureOperationEnum.kJoinOperation)

 

Regards,

Balaji



Balaji
Developer Technical Services
Autodesk Developer Network

Message 9 of 11
Anonymous
in reply to: Balaji_Ram

Actually, my project needs output list of bodies, one per each feature. 

 

Using the join operation, even though spatially they are separate, separate bodies do not get created These new Joined bodies may get stored as lumps. Not sure if I can create bodies out of lumps easily, and then still have body;s feature owner (via faces) as the feature it created.

 

Is there any hint on why NewBody operation fails and Join works? Is there any ownership/associativity issues with the profile or path entities I am using?

Message 10 of 11
Balaji_Ram
in reply to: Anonymous

Hi Yogesh,

 

Sorry for the delay.

 

I have been looking into why the sweep fails with the API when the PartFeatureOperation is set as NewBody, while the Inventor UI seems to create the sweep even when the NewBody option is used.

 

Here are some of the observations so far. I will need to check with our engineering team to know more about this and will keep you updated.

 

1) The behavior is specific to a sheetmetal part document and works ok in a standard part document.

2) When a face already exists at the location where the sketch is created, the API fails during the NewBody feature creation while the JoinOperation succeeds.

3) The sweep created using Inventor UI succeeds, but when digging into how its sweep definition was setup, it turns out that the SweepDefinition uses a NewBody but the sweep feature itself got created using a JoinOperation. This is yet not clear to me on how the feature can get created differently from its definition.

 

I will keep you updated based on what i hear from our engineering team.

 

Regards,

Balaji



Balaji
Developer Technical Services
Autodesk Developer Network

Message 11 of 11
Balaji_Ram
in reply to: Anonymous

Hi Yogesh,

 

I have heard from our engineering team that this is not a expected behavior while creating a new body in a sheetmetal part using the API.

 

I have logged it in our internal database for our engineering team to analyze it.

 

Sorry, at present i do not see any other way to create a sweep in the sheetmetal part document other than choosing the join operation type.

 

Regards,

Balaji



Balaji
Developer Technical Services
Autodesk Developer Network

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

Post to forums  

Autodesk Design & Make Report