Surface Sweep

Surface Sweep

Anonymous
Not applicable
1,542 Views
10 Replies
Message 1 of 11

Surface Sweep

Anonymous
Not applicable

Wish to create a Surface bu sweeping a line along a 'S" shaped path. Start point of the path lies in the plane of profile line, but not touching it. Is it acceptable. Currently sweep is giving exception.

 

Please see attached picture and part.

 

Dim oSweepOne As SweepFeature
oSweepOne = oCompDef.Features.SweepFeatures.AddUsingPath(oProfileOne, path, PartFeatureOperationEnum.kSurfaceOperation, SweepProfileOrientationEnum.kNormalToPath)

 

If the path HAS to touch the profile, than how to move the path to touch the profile?

 

 

0 Likes
1,543 Views
10 Replies
Replies (10)
Message 2 of 11

xiaodong_liang
Autodesk Support
Autodesk Support

Hi,
when I tried with UI, it failed either. The error says:

 

Create Sweep Feature: problems encountered while executing this command.
SurfaceSweepError.ipt: Warnings occurred during update
Sweep4: Problems occurred while building this Sweep
The feature as specified did not change the number of faces (and may not have affected the part).

 

Although I have not figured out how to fix it, it might explain why API failed.

0 Likes
Message 3 of 11

Anonymous
Not applicable

Now I have a case where interactively SWEEP works, but fails in API.

 

               Dim oSweepOne As SweepFeature = Nothing
                Dim oProfileOne As Profile
                oProfileOne = newProfileSketch.Profiles.AddForSurface(newProfileSketch.SketchLines.Item(1))
                oSweepOne = oCompDef.Features.SweepFeatures.AddUsingPath(oProfileOne, newPath, PartFeatureOperationEnum.kSurfaceOperation, SweepProfileOrientationEnum.kNormalToPath)

How do I get more information about the error? Just exception is of no use, actually.

 

SweepFailsInAPI.png

 

Part attached.

 

Sketch9 is midcurve sketch which is the profile.

Sketch10 is the path

 

And the code above fails, whereas works fine intereactively.

 

Another question: sometimes path and profile do not intersect. How to check if they intersect? and if they don't how to offset Path to touch the profile?

 

Code I am trying:

 

               Dim oProfiles As ObjectCollection = GenerateNewProfilesFromMidcurves(newProfileSketch, midcurves)

                ' Get path's sketch
                Dim pathSketch As PlanarSketch = path.Item(1).SketchEntity.Parent

                ' Make a new sketch by copying evrything from path sketch
                Dim newPathSketch As PlanarSketch = Nothing
                If whenSketchCopyWillWOrk Then
                    newPathSketch = CreateNewSketch(pathSketch, True) ' THIS IS CAUSING TRANSFOMRATION BUG, SO FOR NOW, USING THE OLD PROFILE ONLY
                Else
                    pathSketch.Shared = True
                    newPathSketch = pathSketch
                End If

                ' Need any geom entity of the sketch, for shifting/offsetting later
                Dim newPath As Inventor.Path = Nothing
                Dim anySketchEntity As SketchEntity = Nothing
                If newPathSketch.SketchLines.Count > 0 Then
                    anySketchEntity = newPathSketch.SketchLines.Item(1)
                ElseIf newPathSketch.SketchArcs.Count > 0 Then
                    anySketchEntity = newPathSketch.SketchArcs.Item(1)
                Else
                    anySketchEntity = newPathSketch.SketchPoints.Item(1)
                End If

                ' Profile and Path should intersect, but generally they are away. [ BUT, HOW TO CHECK IF THEY ARE INTERSECTING???]
                ' So, project first point on to path's sketch plane, and then offset the path to that point so that SWEEP's profile and path will intersect
                Dim oStartPointProfile As SketchPoint = oProfiles.Item(1).Item(1).Item(1).StartSketchPoint
                Dim wpt As WorkPoint = oCompDef.WorkPoints.AddFixed(oStartPointProfile.Geometry3d, True)
                Dim whenOffsetStartsWorking As Boolean = False
                If whenOffsetStartsWorking Then
                    ' Get a point to offset the path to
                    Dim newProjectedPoint As SketchPoint = newPathSketch.AddByProjectingEntity(wpt)
                    Dim oCollection As ObjectCollection = _invApp.TransientObjects.CreateObjectCollection
                    oCollection.Add(anySketchEntity)
                    Dim offsettedentities As SketchEntitiesEnumerator = newPathSketch.OffsetSketchEntitiesUsingPoint(oCollection, newProjectedPoint.Geometry, True, False)
                    newPath = oCompDef.Features.CreatePath(offsettedentities.Item(1))
                Else
                    newPath = oCompDef.Features.CreatePath(anySketchEntity)
                End If

Ideally I would like to have the SWEPT surface as a NEWBODY, but thats bit far, for now trying to get basic Sweep working.

 

 

0 Likes
Message 4 of 11

xiaodong_liang
Autodesk Support
Autodesk Support
Hi,

could you provide the run-able code project or function? It looks some methods are defined by yourself that cannot be run at my side.

As to checking intersecting, I have not tried, but you might probably be able to 1. build the Brep object from the profile (2D plane) and the path (3d curve)
2. call Plane.IntersectWithCurve to get the intersection points of the Plane and the input curve
3. check those intersection points whether they fall into the region of the profile. This might need some algorithm that judging whether a point locates on a polygon. Sorry I have not an existing code.
0 Likes
Message 5 of 11

Anonymous
Not applicable

Please

  • Download zip having from https://drive.google.com/file/d/0B9ZSXyeZHd37SFhtMEdXM2ktRWM/view?usp=sharing passwd is your first name.
  • Put Breakpoint inside GenerateMidsurfaceFromSweep or Midsurf proejct. Here, I get a sweep feature for wich I am trying to compute a midsurface. Midsurface is created by sweeping midcurve along path offsetted to middle compared to that of the given sweep feature.
  • Run the project, open My Project -> YetToWorkOn -> SheetMetal_Simple_BackPlate_ABEL.ipt Click "Gen Midsurf" button
0 Likes
Message 6 of 11

adam.nagy
Autodesk Support
Autodesk Support

Hi,

 

Sorry, but I have the same request here.

Could you please try to narrow things down on your side so the issue can be reproduced with a simple VBA code?

 

Thank you,



Adam Nagy
Autodesk Platform Services
0 Likes
Message 7 of 11

Anonymous
Not applicable

Attached is the part having profile and path sketches ready.

 

Following is the code:

               Dim oProfileOne As Profile = newProfileSketch.Profiles.AddForSurface(newProfileSketch.SketchLines.Item(1))
                Dim oSweepOne As SweepFeature = Nothing
                    oSweepOne = oCompDef.Features.SweepFeatures.AddUsingPath(oProfileOne, newPath, PartFeatureOperationEnum.kSurfaceOperation, SweepProfileOrientationEnum.kNormalToPath)

Given these two sketches, with Sketch9 as profile and Sketch10 as path, code is not working with API, where as interactively it is working fine.

 

 

0 Likes
Message 8 of 11

adam.nagy
Autodesk Support
Autodesk Support

Thank you.

 

I could reproduce the diffrence in behaviour: the UI works but the code does not.

It seems that the API is more sensitive. 

 

Looks like in case of your sketch with the path the CreatePath() creates something invalid: even though there are supposed to be only three curves there the path will consist of 4 and one of them has a zero length - se blow code that produces this result:

-4.9;  3.29922145229642
-4.9; -3.29922145229644
-4.9; -3.29922145229644
-5.05; -3.29922145229644
-5.05; -3.29922145229644
-5.35; -3.29922145229644
-5.35; -3.29922145229644
-5.35; -3.29922145229644

The code

Sub PrintPoint(p As Point)
    Debug.Print Str(p.X) + "; " + Str(p.Y)
End Sub

Sub PrintPathInfo(p As Path)
    Dim pe As PathEntity
    For Each pe In p
        PrintPoint pe.Curve.StartPoint
        PrintPoint pe.Curve.EndPoint
    Next
End Sub

Sub CreateSweep()
    Dim doc As PartDocument
    Set doc = ThisApplication.ActiveDocument

    Dim oCompDef As PartComponentDefinition
    Set oCompDef = doc.ComponentDefinition
    
    Dim skPath As PlanarSketch
    Set skPath = doc.SelectSet(1)
    
    Dim skProfile As PlanarSketch
    Set skProfile = doc.SelectSet(2)
    
    Dim oPath As Path
    Set oPath = oCompDef.Features.CreatePath(skPath.SketchArcs(1))
    
    Call PrintPathInfo(oPath)
  
    ' Just to clean up after all the tests
    Do While skProfile.Profiles.Count > 0
        skProfile.Profiles(1).Delete
    Loop
  
    Dim oProfile As Profile
    Set oProfile = skProfile.Profiles.AddForSurface()
  
    Dim oSweepOne As SweepFeature
    Set oSweepOne = oCompDef.Features.SweepFeatures.AddUsingPath( _
        oProfile, oPath, kSurfaceOperation, kNormalToPath)
End Sub

If I delete the straight lines in the patch sketch through the UI and recreate them then all is fine.

Could you please let me know how exactly you created those sketch lines? Could you double-check e.g. that none of them is accidentally zero length?



Adam Nagy
Autodesk Platform Services
0 Likes
Message 9 of 11

Anonymous
Not applicable

I debuged further and found that none of the curves in that path are of 0 length. I printed `Z' also and got:

 

-4.9; 3.29922145229642; .15
-4.9; -3.29922145229644; .15

-4.9; -3.29922145229644; .15
-5.05; -3.29922145229644; .15

-5.05; -3.29922145229644; .15
-5.35; -3.29922145229644; .45

-5.35; -3.29922145229644; .45
-5.35; -3.29922145229644; 2.35

 

Attaching part just before the Sweep call as mentioned below:

 

                Dim oProfileOne As Profile = newProfileSketch.Profiles.AddForSurface(newProfileSketch.SketchLines.Item(1))
                Dim oSweepOne As SweepFeature = Nothing
                Try
                    oSweepOne = oCompDef.Features.SweepFeatures.AddUsingPath(oProfileOne, newPath, PartFeatureOperationEnum.kSurfaceOperation, SweepProfileOrientationEnum.kNormalToPath)
                Catch ex As Exception
                    CreateMidurfByOffsettingSweepfaces(sweepFeature, smallestProfileSidelength / 2.0, True)
                End Try

 

0 Likes
Message 10 of 11

adam.nagy
Autodesk Support
Autodesk Support

Yes, but all entities should be in the same plane - in this case the XZ plane.

 

It turns out that the Path contained the entity from the Profile sketch too:

http://adndevblog.typepad.com/manufacturing/2015/10/create-a-sweepfeature-with-path.html



Adam Nagy
Autodesk Platform Services
0 Likes
Message 11 of 11

Anonymous
Not applicable

Thanks a lot for detailed reasoning in the blogpost. Using the code snippet presented there.

0 Likes