Sketch on Flat Pattern Issue

Sketch on Flat Pattern Issue

Curtis_Waguespack
Consultant Consultant
3,008 Views
20 Replies
Message 1 of 21

Sketch on Flat Pattern Issue

Curtis_Waguespack
Consultant
Consultant

Hi everyone,

 

I was trying to help another user with a request, and after posting I noticed an issue. I've looked at it a bit, but I'm not understanding the behavior I'm seeing.

 

Here's a quick video showing the issue, but basically the goal is to create a sketch point at the end of each bend line on the top face of the flat pattern. This works fine with a basic part, until I add a flange. Once the flange is added (or unsuppressed) the sketch points do not land on the end of the bend lines any longer.

 

Can anyone explain this behavior, or offer a suggestion as to how to resolve this?

 

Attached is a 2017 file

 

Thanks,

Curtis

EESignature

Accepted solutions (2)
3,009 Views
20 Replies
Replies (20)
Message 2 of 21

Curtis_Waguespack
Consultant
Consultant

accompanying code:

 

'[ edit these variables as needed
sSketchName = "Flat Pattern Sketch"
sHoleName = "Locator Holes"
oOffset = 0.100 in'defines offset from edge of flat pattern
oDiameter = 0.125 in 'defines hole diameter
']	

'  a reference to the active document.
Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.ActiveDocument

'verify document type is sheet metal
If oPartDoc.ComponentDefinition.Type <> 150995200 Then
	MessageBox.Show("File is not a sheet metal part.", "iLogic")
	Exit Sub
End If

Dim oCompDef As SheetMetalComponentDefinition
oCompDef = oPartDoc.ComponentDefinition

' Check to make sure a flat pattern is open.
If Not TypeOf ThisApplication.ActiveEditObject Is FlatPattern Then
	Try
		If oCompDef.HasFlatPattern = False Then
			oCompDef.Unfold
		Else
			oCompDef.FlatPattern.Edit
		End If
	Catch
		MessageBox.Show("Error editting the flat pattern.", "iLogic")

	End Try
End If

'  a reference to the active flat pattern.
Dim oFlatPattern As FlatPattern
oFlatPattern = ThisApplication.ActiveEditObject

'clean up existing holes
Dim oHole As HoleFeature
For Each oHole In oFlatPattern.Features.HoleFeatures
	oHole.Delete
Next
 
Dim oFace As Face
'oFace = oFlatPattern.BottomFace
oFace = oFlatPattern.TopFace

Dim oSketch As PlanarSketch

'clean up existing sketch
For Each oSketch In oFlatPattern.Sketches
	If oSketch.Name = sSketchName Then
		oSketch.Delete
	End If
Next

' Create a new sketch.  The second argument specifies to include/not include
' the edges of the face in the sketch.
oSketch = oFlatPattern.Sketches.Add(oFace, False)

' Change the name.
oSketch.Name = sSketchName

' Create a new object collection for the hole center points.
oHoleCenters = ThisApplication.TransientObjects.CreateObjectCollection

Dim oTG As TransientGeometry
oTG = ThisApplication.TransientGeometry	
	
Dim oPoint As Point2d
Dim oEdge As Edge


Dim oEdges As Edges

' Get all Bend UP edges
'where true = top face
oEdges = _
oFlatPattern.GetEdgesOfType( _
FlatPatternEdgeTypeEnum.kBendUpFlatPatternEdge, True) 'true = top face

For Each oEdge In oEdges
	oPoint = oTG.CreatePoint2d(oEdge.StartVertex.Point.x, _
	oEdge.StartVertex.Point.y )
	oHoleCenters.Add ( oSketch.SketchPoints.Add(oPoint, True))
	oPoint = oTG.CreatePoint2d(oEdge.StopVertex.Point.x, _
	oEdge.StopVertex.Point.y )
	oHoleCenters.Add ( oSketch.SketchPoints.Add(oPoint, True))
Next

' Get all Bend Down edges
'where true = top face
oEdges = _
oFlatPattern.GetEdgesOfType( _
FlatPatternEdgeTypeEnum.kBendDownFlatPatternEdge, True) 

For Each oEdge In oEdges
	oPoint = oTG.CreatePoint2d(oEdge.StartVertex.Point.x, _
	oEdge.StartVertex.Point.y )
	oHoleCenters.Add ( oSketch.SketchPoints.Add(oPoint, True))
	oPoint = oTG.CreatePoint2d(oEdge.StopVertex.Point.x, _
	oEdge.StopVertex.Point.y )
	oHoleCenters.Add ( oSketch.SketchPoints.Add(oPoint, True))
Next

EESignature

Message 3 of 21

chrisw01a
Collaborator
Collaborator

Well I came over here to ask the exact same question and here you are 🙂

 

Looking forward to any replies...

 

Chris

0 Likes
Message 4 of 21

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

Hi Curtis,

 

Alternatively, Points can be drawn on flat pattern. Please find the following iLogic code for the same.

 

Initially, edge will be projected to sketch line. Using end point and start point of same line, points are drawn in sketch.

 

 

'[ edit these variables as needed
sSketchName = "Flat Pattern Sketch"
sHoleName = "Locator Holes"
oOffset = 0.100 in'defines offset from edge of flat pattern
oDiameter = 0.125 in 'defines hole diameter
']	

'  a reference to the active document.
Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.ActiveDocument

'verify document type is sheet metal
If oPartDoc.ComponentDefinition.Type <> 150995200 Then
	MessageBox.Show("File is not a sheet metal part.", "iLogic")
	Exit Sub
End If

Dim oCompDef As SheetMetalComponentDefinition
oCompDef = oPartDoc.ComponentDefinition

' Check to make sure a flat pattern is open.
If Not TypeOf ThisApplication.ActiveEditObject Is FlatPattern Then
	Try
		If oCompDef.HasFlatPattern = False Then
			oCompDef.Unfold
		Else
			oCompDef.FlatPattern.Edit
		End If
	Catch
		MessageBox.Show("Error editting the flat pattern.", "iLogic")

	End Try
End If

'  a reference to the active flat pattern.
Dim oFlatPattern As FlatPattern
oFlatPattern = ThisApplication.ActiveEditObject

'clean up existing holes
Dim oHole As HoleFeature
For Each oHole In oFlatPattern.Features.HoleFeatures
	oHole.Delete
Next
 
Dim oFace As Face
'oFace = oFlatPattern.BottomFace
oFace = oFlatPattern.TopFace

Dim oSketch As PlanarSketch

'clean up existing sketch
For Each oSketch In oFlatPattern.Sketches
	If oSketch.Name = sSketchName Then
		oSketch.Delete
	End If
Next

' Create a new sketch.  The second argument specifies to include/not include
' the edges of the face in the sketch.
oSketch = oFlatPattern.Sketches.Add(oFace, False)

' Change the name.
oSketch.Name = sSketchName

' Create a new object collection for the hole center points.
oHoleCenters = ThisApplication.TransientObjects.CreateObjectCollection

Dim oTG As TransientGeometry
oTG = ThisApplication.TransientGeometry	
	
Dim oPoint As Point2d
Dim oEdge As Edge


Dim oEdges As Edges

' Get all Bend UP edges
'where true = top face
oEdges = _
oFlatPattern.GetEdgesOfType( _
FlatPatternEdgeTypeEnum.kBendUpFlatPatternEdge, True) 'true = top face

For Each oEdge In oEdges
    Dim line As SketchLine = oSketch.AddByProjectingEntity(oEdge)
    oHoleCenters.Add(oSketch.SketchPoints.Add(line.StartSketchPoint.Geometry, True))

    oHoleCenters.Add(oSketch.SketchPoints.Add(line.EndSketchPoint.Geometry, True))

    line.Delete()
Next

' Get all Bend Down edges
'where true = top face
oEdges = _
oFlatPattern.GetEdgesOfType( _
FlatPatternEdgeTypeEnum.kBendDownFlatPatternEdge, True) 

For Each oEdge In oEdges
    Dim line As SketchLine = oSketch.AddByProjectingEntity(oEdge)
    oHoleCenters.Add(oSketch.SketchPoints.Add(line.StartSketchPoint.Geometry, True))

    oHoleCenters.Add(oSketch.SketchPoints.Add(line.EndSketchPoint.Geometry, True))

    line.Delete()
Next

 

Please feel free to contact if there is any doubt.

 

If solves your problem, click on "Accept as solution" or give a "Kudo".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 5 of 21

chrisw01a
Collaborator
Collaborator

CHANDRA,

 

Thanks for your input here.

 

You have the right idea, but is there any way to get the point to come in .100" from the end points?

Is it possible to apply a coincident constraint between the points and the projected bend line?

 

I have attached an example.

 

Take care

Chris

0 Likes
Message 6 of 21

Curtis_Waguespack
Consultant
Consultant

Hi @chandra.shekar.g,

 

Thanks for your previous help on this. Your reply did answer my question, however I was working with chrisw01a on a request to add holes at the sketch points.

 

His requirement is that the holes are placed 0.1 to the inside of the flat pattern. I've not had time to look at this in depth, but I've not been able to determine the unpredictable behavior or the bend line direction.

 

In this video you can see how they flip every time the sketch is re-created. Also note that is I suppress a flange then they no longer flip.

 

Attached is a 2017 part file example.

 

Can you explain this behavior, or is the another approach that would work better for placing these holes?

 

Thanks again,

Curtis

 

 

 

 

EESignature

Message 7 of 21

chandra.shekar.g
Autodesk Support
Autodesk Support

Hi @Curtis_Waguespack, @chrisw01a,

 

A tiny changes are made to "Create Sketch Points on Bend Lines" and "Suppress Flange". Please find updated iLogic code in the following.

 

Changes in "Create Sketch Points on Bend Lines" iLogic rule.

 

'[ edit these variables as needed
sSketchName = "Flat Pattern Sketch"
sHoleName = "Locator Holes"
oOffset = 0.3 'defines offset from edge of flat pattern
oDiameter = 0.125 'defines hole diameter
']	

'  a reference to the active document.
Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.ActiveDocument

'verify document type is sheet metal
If oPartDoc.ComponentDefinition.Type <> 150995200 Then
	MessageBox.Show("File is not a sheet metal part.", "iLogic")
	Exit Sub
End If

Dim oCompDef As SheetMetalComponentDefinition
oCompDef = oPartDoc.ComponentDefinition

' Check to make sure a flat pattern is open.
If Not TypeOf ThisApplication.ActiveEditObject Is FlatPattern Then
	Try
		If oCompDef.HasFlatPattern = False Then
			oCompDef.Unfold
		Else
			oCompDef.FlatPattern.Edit
		End If
	Catch
		MessageBox.Show("Error editting the flat pattern.", "iLogic")

	End Try
End If

'  a reference to the active flat pattern.
Dim oFlatPattern As FlatPattern
oFlatPattern = ThisApplication.ActiveEditObject

'clean up existing holes
Dim oHole As HoleFeature
For Each oHole In oFlatPattern.Features.HoleFeatures
	oHole.Delete
Next
 
Dim oFace As Face
'oFace = oFlatPattern.BottomFace
oFace = oFlatPattern.TopFace

Dim oSketch As PlanarSketch

'clean up existing sketch
For Each oSketch In oFlatPattern.Sketches
	If oSketch.Name = sSketchName Then
		oSketch.Delete
	End If
Next

' Create a new sketch.  The second argument specifies to include/not include
' the edges of the face in the sketch.
oSketch = oFlatPattern.Sketches.Add(oFace, False)

' Change the name.
oSketch.Name = sSketchName

' Create a new object collection for the hole center points.
oHoleCenters = ThisApplication.TransientObjects.CreateObjectCollection

Dim oTG As TransientGeometry
oTG = ThisApplication.TransientGeometry	
	
Dim oPoint As Point2d
Dim oSketchPoint As SketchPoint
'oOffset = oOffset * 2.5400013716 'converts cm to inches

Dim oEdge As Edge
Dim oEdges As Edges

' Get all Bend UP edges
'where true = top face
oEdges = _
oFlatPattern.GetEdgesOfType( _
FlatPatternEdgeTypeEnum.kBendUpFlatPatternEdge, True) 

For Each oEdge In oEdges
    Dim line As SketchLine = oSketch.AddByProjectingEntity(oEdge)

    Dim startPt As Point2d
    startPt = line.StartSketchPoint.Geometry

    Dim endPt As Point2d
    endPt = line.EndSketchPoint.Geometry

    If startPt.Y < endPt.Y Then
        startPt.Y = startPt.Y + oOffset
        endPt.Y = endPt.Y - oOffset
    Else
        startPt.Y = startPt.Y - oOffset
        endPt.Y = endPt.Y + oOffset
    End If

    Dim startSkPt As SketchPoint
    startSkPt = oSketch.SketchPoints.Add(startPt, True)
    oSketch.GeometricConstraints.AddGround(startSkPt)

    Dim endSkPt As SketchPoint
    endSkPt = oSketch.SketchPoints.Add(endPt, True)
    oSketch.GeometricConstraints.AddGround(endSkPt)

    oHoleCenters.Add(startSkPt)

    oHoleCenters.Add(endSkPt)

    line.Delete()
Next

' Get all Bend Down edges
'where true = top face
oEdges = _
oFlatPattern.GetEdgesOfType( _
FlatPatternEdgeTypeEnum.kBendDownFlatPatternEdge, True) 

For Each oEdge In oEdges
    Dim line As SketchLine = oSketch.AddByProjectingEntity(oEdge)

    Dim startPt As Point2d
    startPt = line.StartSketchPoint.Geometry

    Dim endPt As Point2d
    endPt = line.EndSketchPoint.Geometry

    If startPt.Y < endPt.Y Then
        startPt.Y = startPt.Y + oOffset
        endPt.Y = endPt.Y - oOffset
    Else
        startPt.Y = startPt.Y - oOffset
        endPt.Y = endPt.Y + oOffset
    End If

    Dim startSkPt As SketchPoint
    startSkPt = oSketch.SketchPoints.Add(startPt, True)
    oSketch.GeometricConstraints.AddGround(startSkPt)

    Dim endSkPt As SketchPoint
    endSkPt = oSketch.SketchPoints.Add(endPt, True)
    oSketch.GeometricConstraints.AddGround(endSkPt)

    oHoleCenters.Add(startSkPt)

    oHoleCenters.Add(endSkPt)

    line.Delete()
Next

    ' Create the hole feature.
    oHole =  oFlatPattern.Features.HoleFeatures.AddDrilledByThroughAllExtent( _
                            oHoleCenters, oDiameter , kPositiveExtentDirection)
							'oHoleCenters, oDiameter * 2.5400013716 , kPositiveExtentDirection)

	oHole.Name = sHoleName
	oSketch.Visible = True

Changes in "Supress Flange" iLogic rule.

 

Feature.IsActive("Flange1") = Not Feature.IsActive("Flange1")
iLogicVb.RunRule("Create Sketch Points on Bend Lines")

Please feel free to contact if there is any doubt.

 

If solves your problem, click on "Accept as solution" / give a "Kudo".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 8 of 21

chrisw01a
Collaborator
Collaborator

Wow, we are so close!

 

However, there is an issue when the bend line is horizontal as the offset is going the wrong direction.  See attached part.

 

Also, I see that you are grounding the sketch points.  Is it possible to create a coincident constraint between the sketch point and the projected bend line?

The reason is because if the part geometry is changed, then the code would need to be ran again.

 

Anyways.  I am so thankful for you help.

 

Chris

0 Likes
Message 9 of 21

Curtis_Waguespack
Consultant
Consultant

Hi @chrisw01a,

 

So I was able to look at this a bit and have updated the attached 2017 file to fully constrain the sketch so that it will update if/when the part size changes.

 

As for determining which way the bend lines are oriented, I did not get a chance to look at that part of this today, maybe @chandra.shekar.g will have a chance to help with that part of it.

 

Note to I took a minute to clean up the code and re-organize and condense it a bit, so it might look a bit different.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

Sub Main
'[ edit these variables as needed
sSketchName = "Flat Pattern Sketch"
sHoleName = "Locator Holes"
oOffset = 0.1 'defines offset from edge of flat pattern
oDiameter = 0.125 'defines hole diameter
']	

'  a reference to the active document.
Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.ActiveDocument

'verify document type is sheet metal
If oPartDoc.ComponentDefinition.Type <> 150995200 Then
	MessageBox.Show("File is not a sheet metal part.", "iLogic")
	Exit Sub
End If

Dim oCompDef As SheetMetalComponentDefinition
oCompDef = oPartDoc.ComponentDefinition

' Check to make sure a flat pattern is open.
If Not TypeOf ThisApplication.ActiveEditObject Is FlatPattern Then
	Try
		If oCompDef.HasFlatPattern = False Then
			oCompDef.Unfold
		Else
			oCompDef.FlatPattern.Edit
		End If
	Catch
		MessageBox.Show("Error editting the flat pattern.", "iLogic")

	End Try
End If

'  a reference to the active flat pattern.
Dim oFlatPattern As FlatPattern
oFlatPattern = ThisApplication.ActiveEditObject

'clean up existing holes
Dim oHole As HoleFeature
For Each oHole In oFlatPattern.Features.HoleFeatures
	oHole.Delete
Next
 
Dim oFace As Face
'oFace = oFlatPattern.BottomFace
oFace = oFlatPattern.TopFace

Dim oSketch As PlanarSketch

'clean up existing sketch
For Each oSketch In oFlatPattern.Sketches
	If oSketch.Name = sSketchName Then
		oSketch.Delete
	End If
Next

' Create a new sketch.  The second argument specifies to include/not include
' the edges of the face in the sketch.
oSketch = oFlatPattern.Sketches.Add(oFace, False)

' Change the name.
oSketch.Name = sSketchName
	
'Dim oPoint As Point2d
Dim oSketchPoint As SketchPoint
oOffset = oOffset * 2.5400013716 'converts cm to inches

Dim oEdges As Edges

' Create a new object collection for the hole center points.
oHoleCenters = ThisApplication.TransientObjects.CreateObjectCollection

' Get all Bend UP edges
'where true = top face
oEdges = _
oFlatPattern.GetEdgesOfType( _
FlatPatternEdgeTypeEnum.kBendUpFlatPatternEdge, True) 
Call Create_SketchPoints(oSketch, oEdges, oHoleCenters, oOffset)

' Get all Bend Down edges
'where true = top face
oEdges = _
oFlatPattern.GetEdgesOfType( _
FlatPatternEdgeTypeEnum.kBendDownFlatPatternEdge, True) 
Call Create_SketchPoints(oSketch, oEdges, oHoleCenters, oOffset )

' Create the hole feature.
oHole =  oFlatPattern.Features.HoleFeatures.AddDrilledByThroughAllExtent( _
						oHoleCenters, oDiameter * 2.5400013716 , kPositiveExtentDirection)

oHole.Name = sHoleName

End Sub

Sub Create_SketchPoints (oSketch As Sketch, oEdges As Edges, oHoleCenters As ObjectCollection, oOffset As Double)


For Each oEdge In oEdges
    Dim line As SketchLine = oSketch.AddByProjectingEntity(oEdge)

    Dim startPt As Point2d
    startPt = line.StartSketchPoint.Geometry
	
	
    Dim endPt As Point2d
    endPt = line.EndSketchPoint.Geometry
	
	
    If startPt.Y < endPt.Y Then
        startPt.Y = startPt.Y + oOffset
        endPt.Y = endPt.Y - oOffset
    Else
        startPt.Y = startPt.Y - oOffset
        endPt.Y = endPt.Y + oOffset
    End If
	

    Dim startSkPt As SketchPoint
    startSkPt = oSketch.SketchPoints.Add(startPt, True)
	oSketch.GeometricConstraints.AddCoincident(startSkPt,line)
	oSketch.DimensionConstraints.AddTwoPointDistance _
	(startSkPt,line.StartSketchPoint,DimensionOrientationEnum.kVerticalDim,startPt)

    Dim endSkPt As SketchPoint
    endSkPt = oSketch.SketchPoints.Add(endPt, True)
    oSketch.GeometricConstraints.AddCoincident(endSkPt,line)
	oSketch.DimensionConstraints.AddTwoPointDistance _
	(endSkPt,line.EndSketchPoint,DimensionOrientationEnum.kVerticalDim,endPt)
	
    oHoleCenters.Add(startSkPt)
    oHoleCenters.Add(endSkPt)

    oHoleCenters.Add(startSkPt)

    oHoleCenters.Add(endSkPt)

Next

End Sub

EESignature

Message 10 of 21

chandra.shekar.g
Autodesk Support
Autodesk Support

Thanks @Curtis_Waguespack for constraints code,

 

Hi @chrisw01a,

 

The following iLogic code handles both horizontal and vertical lines.

 

Sub Main
'[ edit these variables as needed
sSketchName = "Flat Pattern Sketch"
sHoleName = "Locator Holes"
oOffset = 0.1 'defines offset from edge of flat pattern
oDiameter = 0.125 'defines hole diameter
']	

'  a reference to the active document.
Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.ActiveDocument

'verify document type is sheet metal
If oPartDoc.ComponentDefinition.Type <> 150995200 Then
	MessageBox.Show("File is not a sheet metal part.", "iLogic")
	Exit Sub
End If

Dim oCompDef As SheetMetalComponentDefinition
oCompDef = oPartDoc.ComponentDefinition

' Check to make sure a flat pattern is open.
If Not TypeOf ThisApplication.ActiveEditObject Is FlatPattern Then
	Try
		If oCompDef.HasFlatPattern = False Then
			oCompDef.Unfold
		Else
			oCompDef.FlatPattern.Edit
		End If
	Catch
		MessageBox.Show("Error editting the flat pattern.", "iLogic")

	End Try
End If

'  a reference to the active flat pattern.
Dim oFlatPattern As FlatPattern
oFlatPattern = ThisApplication.ActiveEditObject

'clean up existing holes
Dim oHole As HoleFeature
For Each oHole In oFlatPattern.Features.HoleFeatures
	oHole.Delete
Next
 
Dim oFace As Face
'oFace = oFlatPattern.BottomFace
oFace = oFlatPattern.TopFace

Dim oSketch As PlanarSketch

'clean up existing sketch
For Each oSketch In oFlatPattern.Sketches
	If oSketch.Name = sSketchName Then
		oSketch.Delete
	End If
Next

' Create a new sketch.  The second argument specifies to include/not include
' the edges of the face in the sketch.
oSketch = oFlatPattern.Sketches.Add(oFace, False)

' Change the name.
oSketch.Name = sSketchName
	
'Dim oPoint As Point2d
Dim oSketchPoint As SketchPoint
oOffset = oOffset * 2.5400013716 'converts cm to inches

Dim oEdges As Edges

' Create a new object collection for the hole center points.
oHoleCenters = ThisApplication.TransientObjects.CreateObjectCollection

' Get all Bend UP edges
'where true = top face
oEdges = _
oFlatPattern.GetEdgesOfType( _
FlatPatternEdgeTypeEnum.kBendUpFlatPatternEdge, True) 
Call Create_SketchPoints(oSketch, oEdges, oHoleCenters, oOffset)

' Get all Bend Down edges
'where true = top face
oEdges = _
oFlatPattern.GetEdgesOfType( _
FlatPatternEdgeTypeEnum.kBendDownFlatPatternEdge, True) 
Call Create_SketchPoints(oSketch, oEdges, oHoleCenters, oOffset )

' Create the hole feature.
oHole =  oFlatPattern.Features.HoleFeatures.AddDrilledByThroughAllExtent( _
						oHoleCenters, oDiameter * 2.5400013716 , kPositiveExtentDirection)

oHole.Name = sHoleName

End Sub

Sub Create_SketchPoints (oSketch As Sketch, oEdges As Edges, oHoleCenters As ObjectCollection, oOffset As Double)


For Each oEdge In oEdges
    Dim line As SketchLine = oSketch.AddByProjectingEntity(oEdge)

    Dim startPt As Point2d
    startPt = line.StartSketchPoint.Geometry	
	
    Dim endPt As Point2d
    endPt = line.EndSketchPoint.Geometry	
	
    Dim startSkPt As SketchPoint
    Dim endSkPt As SketchPoint

    If Round(startPt.Y, 4) = Round(endPt.Y,4) Then

        If startPt.X < endPt.X Then
            startPt.X = startPt.X + oOffset
            endPt.X = endPt.X - oOffset
        Else
            startPt.X = startPt.X - oOffset
            endPt.X = endPt.X + oOffset
        End If

        startSkPt = oSketch.SketchPoints.Add(startPt, True)
        oSketch.GeometricConstraints.AddCoincident(startSkPt, line)
        oSketch.DimensionConstraints.AddTwoPointDistance _
        (startSkPt, line.StartSketchPoint, DimensionOrientationEnum.kHorizontalDim, startPt)


        endSkPt = oSketch.SketchPoints.Add(endPt, True)
        oSketch.GeometricConstraints.AddCoincident(endSkPt, line)
        oSketch.DimensionConstraints.AddTwoPointDistance _
        (endSkPt, line.EndSketchPoint, DimensionOrientationEnum.kHorizontalDim, endPt)

    Else if Round(startPt.X, 4) = Round(endPt.X,4) Then

        If startPt.Y < endPt.Y Then
            startPt.Y = startPt.Y + oOffset
            endPt.Y = endPt.Y - oOffset
        Else
            startPt.Y = startPt.Y - oOffset
            endPt.Y = endPt.Y + oOffset
        End If

        startSkPt = oSketch.SketchPoints.Add(startPt, True)
        oSketch.GeometricConstraints.AddCoincident(startSkPt, line)
        oSketch.DimensionConstraints.AddTwoPointDistance _
        (startSkPt, line.StartSketchPoint, DimensionOrientationEnum.kVerticalDim, startPt)


        endSkPt = oSketch.SketchPoints.Add(endPt, True)
        oSketch.GeometricConstraints.AddCoincident(endSkPt, line)
        oSketch.DimensionConstraints.AddTwoPointDistance _
        (endSkPt, line.EndSketchPoint, DimensionOrientationEnum.kVerticalDim, endPt)

    End If
	
    oHoleCenters.Add(startSkPt)
    oHoleCenters.Add(endSkPt)    

Next

End Sub

Please feel free to contact if there is any doubt.

 

If solves your problem, click on "Accept as solution" / give a "Kudo".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 11 of 21

chrisw01a
Collaborator
Collaborator

It is truly amazing what you can do when you know what you are doing.  

 

So it looks like this works really well on parts that have horizontal and vertical bends, but the first thing I ran across this morning was a part that has bend lines at an angle (please see attached part) and it doesn't like that.

 

Are we able to handle this or are we getting to the limit of capability here?  I presume the offsets / dimensions would have to be "aligned" type.

 

I would like to make sure you guys know how much I appreciate what you have done here.  Is there anything I can do for you?

Can you accept a donation or is that against the rules?

 

Have a great day.

Chris

 

0 Likes
Message 12 of 21

Curtis_Waguespack
Consultant
Consultant

Hi @chrisw01a,

 

Ok here's the latest. I redid the method of locating the hole centers by creating a circle on the bend line start and end points and then finding the intersection, so this should get the offset correct regardless of the bend orientation.

 

See attached 2017 file.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

Sub Main
'[ edit these variables as needed
sSketchName = "Flat Pattern Sketch"
sHoleName = "Locator Holes"
oOffset = 0.1 'defines offset from edge of flat pattern
oDiameter = 0.125 'defines hole diameter
']	

'  a reference to the active document.
Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.ActiveDocument

'verify document type is sheet metal
If oPartDoc.ComponentDefinition.Type <> 150995200 Then
	MessageBox.Show("File is not a sheet metal part.", "iLogic")
	Exit Sub
End If

Dim oCompDef As SheetMetalComponentDefinition
oCompDef = oPartDoc.ComponentDefinition

' Check to make sure a flat pattern is open.
If Not TypeOf ThisApplication.ActiveEditObject Is FlatPattern Then
	Try
		If oCompDef.HasFlatPattern = False Then
			oCompDef.Unfold
		Else
			oCompDef.FlatPattern.Edit
		End If
	Catch
		MessageBox.Show("Error editting the flat pattern.", "iLogic")

	End Try
End If

'  a reference to the active flat pattern.
Dim oFlatPattern As FlatPattern
oFlatPattern = ThisApplication.ActiveEditObject

'clean up existing holes
Dim oHole As HoleFeature
For Each oHole In oFlatPattern.Features.HoleFeatures
	oHole.Delete
Next
 
Dim oFace As Face
oFace = oFlatPattern.TopFace

Dim oSketch As PlanarSketch

'clean up existing sketch
For Each oSketch In oFlatPattern.Sketches
	If oSketch.Name = sSketchName Then
		oSketch.Delete
	End If
Next

' Create a new sketch.  
' the Second argument specifies To include/Not include
' the edges of the face in the sketch.
oSketch = oFlatPattern.Sketches.Add(oFace, False)

' Change the name.
oSketch.Name = sSketchName
	
'Dim oPoint As Point2d
Dim oSketchPoint As SketchPoint
oOffset = oOffset * 2.5400013716 'converts cm to inches

Dim oEdges As Edges

' Create a new object collection for the hole center points.
oHoleCenters = ThisApplication.TransientObjects.CreateObjectCollection

' Get all Bend UP edges
'where true = top face
oEdges = _
oFlatPattern.GetEdgesOfType( _
FlatPatternEdgeTypeEnum.kBendUpFlatPatternEdge, True) 

'process the Bend Edges
Call Create_SketchPoints(oSketch, oEdges, oHoleCenters, oOffset)

' Get all Bend Down edges
'where true = top face
oEdges = _
oFlatPattern.GetEdgesOfType( _
FlatPatternEdgeTypeEnum.kBendDownFlatPatternEdge, True) 

'process the Bend Edges
Call Create_SketchPoints(oSketch, oEdges, oHoleCenters, oOffset )

' Create the hole feature
oHole =  oFlatPattern.Features.HoleFeatures.AddDrilledByThroughAllExtent( _
		oHoleCenters, oDiameter * 2.5400013716 , kPositiveExtentDirection)

oHole.Name = sHoleName

oCompDef.FlatPattern.ExitEdit
oPartDoc.Save

End Sub

Sub Create_SketchPoints _
(oSketch As Sketch, oEdges As Edges, _
oHoleCenters As ObjectCollection, oOffset As Double)

    ' Set a reference to the transient geometry object.
    Dim oTransGeom As TransientGeometry
    oTransGeom = ThisApplication.TransientGeometry


For Each oEdge In oEdges

	'create line
    Dim skLine As SketchLine 
	skLine = oSketch.AddByProjectingEntity(oEdge)
	
	Dim oLineSegment1 As LineSegment2d
	oLineSegment1 = skLine.Geometry
	
    Dim startPt As Point2d
    startPt = skLine.StartSketchPoint.Geometry	
	
    Dim endPt As Point2d
    endPt = skLine.EndSketchPoint.Geometry	
	
    Dim startSkPt As SketchPoint
    Dim endSkPt As SketchPoint
	
	Dim oInterSectPoint As Point2d
    Dim oCircle As SketchCircle		

'start point
	'create circle
    oCircle = oSketch.SketchCircles.AddByCenterRadius(startPt, oOffset)
	
	'find intersection of circle and line
	oInterSectPoint = oLineSegment1.IntersectWithCurve(oCircle.Geometry).Item(1)
	'create point for hole
	startSkPt = oSketch.SketchPoints.Add(oInterSectPoint, True)
	
	'constrain geometry
	oCircle.Construction = True
	oSketch.DimensionConstraints.AddDiameter (oCircle, startPt ) 
	oSketch.GeometricConstraints.AddCoincident(startSkPt, skLine)
	oSketch.GeometricConstraints.AddCoincident(startSkPt, oCircle)
	oSketch.GeometricConstraints.AddCoincident _
	(skLine.StartSketchPoint, oCircle.CenterSketchPoint)	
	
	'add to hole center collection
	oHoleCenters.Add(startSkPt)
	
'end point
	'create circle
    oCircle = oSketch.SketchCircles.AddByCenterRadius(endPt, oOffset)
	
	'find intersection of circle and line
	oInterSectPoint = oLineSegment1.IntersectWithCurve(oCircle.Geometry).Item(1)
	endSkPt = oSketch.SketchPoints.Add(oInterSectPoint, True)
	
	'constrain geometry
	oCircle.Construction = True
	oSketch.DimensionConstraints.AddDiameter (oCircle, endPt ) 
	oSketch.GeometricConstraints.AddCoincident(endSkPt, skLine)
	oSketch.GeometricConstraints.AddCoincident(endSkPt, oCircle)
	oSketch.GeometricConstraints.AddCoincident _
	(skLine.EndSketchPoint, oCircle.CenterSketchPoint)
	
    'add to hole center collection
    oHoleCenters.Add(endSkPt)    

Next

End Sub

EESignature

Message 13 of 21

chrisw01a
Collaborator
Collaborator

It looks like you nailed it this time!

 

This is going to be a huge time saver and mouse hand saver.

 

Really the only other thing that I could think of to make this great is if I could run a second rule from a .idw sheet and have it iterate through all views on the sheet and add the center punch to each part.  I don’t think there would be too awful much programming involved there.  It could call this rule that way I could still run this one on demand if I needed to.

 

You guys are awesome.

 

Chris

0 Likes
Message 14 of 21

Curtis_Waguespack
Consultant
Consultant

@chrisw01a wrote:

... have it iterate through all views on the sheet and add the center punch to each part. 



Hi chrisw01a,

 

When you say "add the center punch" can you clarify? Do you mean a center mark for each of these holes, or is this something else? Can you provide a screen shot if you think that will help (I don't have Inventor 2018 loaded on this computer).

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

EESignature

0 Likes
Message 15 of 21

Curtis_Waguespack
Consultant
Consultant

Hi chrisw01a,

 

Try running this rule from the drawing and let me know if this does what you're after.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

Sub Main
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

Dim Sheet As Inventor.Sheet
Dim oView As DrawingView
Dim oAutoCenterLines As AutomatedCenterlineSettings
Dim oNameList As New ArrayList
oNameList.Clear

'iterate through the sheets
For Each oSheet In oDrawDoc.Sheets
	'iterate through the views
	For Each oView In oSheet.DrawingViews
		oModDoc = ActiveSheet.View(oView.Name).ModelDocument
		
		'determine if the model is a sheet metal part
		If oModDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then 
		
			'check if list contains name
			'indicating it's already been processed
			If oNameList.Contains(oModDoc.FullFileName) Then 
				'do nothing
			Else
				'add to list
				oNameList.Add(oModDoc.FullFileName)
				'process flat pattern
				Call FlattPattern_sub(oModDoc.FullFileName)
			
			End If
			
			'set automatic center line settings
			oView.GetAutomatedCenterlineSettings(oAutoCenterLines)
				oAutoCenterLines.ApplyToHoles = True
				oAutoCenterLines.ApplyToPunches = True
				
			'get automatic center lines	
			oView.SetAutomatedCenterlineSettings(oAutoCenterLines)				
			
		End If
	Next
Next		

End Sub

Sub FlattPattern_sub(oDoc As String)
'[ edit these variables as needed
sSketchName = "Flat Pattern Sketch"
sHoleName = "Locator Holes"
oOffset = 0.1 'defines offset from edge of flat pattern
oDiameter = 0.125 'defines hole diameter
']	

'open the sheet metal part file
oPartDoc = ThisApplication.Documents.Open(oDoc, True) 


'verify document type is sheet metal
If oPartDoc.ComponentDefinition.Type <> 150995200 Then
	MessageBox.Show("File is not a sheet metal part.", "iLogic")
	Exit Sub
End If

Dim oCompDef As SheetMetalComponentDefinition
oCompDef = oPartDoc.ComponentDefinition

' Check to make sure a flat pattern is open.
If Not TypeOf ThisApplication.ActiveEditObject Is FlatPattern Then
	Try
		If oCompDef.HasFlatPattern = False Then
			oCompDef.Unfold
		Else
			oCompDef.FlatPattern.Edit
		End If
	Catch
		MessageBox.Show("Error editting the flat pattern.", "iLogic")

	End Try
End If

'  a reference to the active flat pattern.
Dim oFlatPattern As FlatPattern
oFlatPattern = ThisApplication.ActiveEditObject

'clean up existing holes
Dim oHole As HoleFeature
For Each oHole In oFlatPattern.Features.HoleFeatures
	oHole.Delete
Next
 
Dim oFace As Face
oFace = oFlatPattern.TopFace

Dim oSketch As PlanarSketch

'clean up existing sketch
For Each oSketch In oFlatPattern.Sketches
	If oSketch.Name = sSketchName Then
		oSketch.Delete
	End If
Next

' Create a new sketch.  
' the Second argument specifies To include/Not include
' the edges of the face in the sketch.
oSketch = oFlatPattern.Sketches.Add(oFace, False)

' Change the name.
oSketch.Name = sSketchName
	
'Dim oPoint As Point2d
Dim oSketchPoint As SketchPoint
oOffset = oOffset * 2.5400013716 'converts cm to inches

Dim oEdges As Edges

' Create a new object collection for the hole center points.
oHoleCenters = ThisApplication.TransientObjects.CreateObjectCollection

' Get all Bend UP edges
'where true = top face
oEdges = _
oFlatPattern.GetEdgesOfType( _
FlatPatternEdgeTypeEnum.kBendUpFlatPatternEdge, True) 

'process the Bend Edges
Call Create_SketchPoints(oSketch, oEdges, oHoleCenters, oOffset)

' Get all Bend Down edges
'where true = top face
oEdges = _
oFlatPattern.GetEdgesOfType( _
FlatPatternEdgeTypeEnum.kBendDownFlatPatternEdge, True) 

'process the Bend Edges
Call Create_SketchPoints(oSketch, oEdges, oHoleCenters, oOffset )

' Create the hole feature
oHole =  oFlatPattern.Features.HoleFeatures.AddDrilledByThroughAllExtent( _
		oHoleCenters, oDiameter * 2.5400013716 , kPositiveExtentDirection)

oHole.Name = sHoleName

oCompDef.FlatPattern.ExitEdit
oPartDoc.Save
oPartDoc.Close
End Sub

Sub Create_SketchPoints _
(oSketch As Sketch, oEdges As Edges, _
oHoleCenters As ObjectCollection, oOffset As Double)

    ' Set a reference to the transient geometry object.
    Dim oTransGeom As TransientGeometry
    oTransGeom = ThisApplication.TransientGeometry


For Each oEdge In oEdges

	'create line
    Dim skLine As SketchLine 
	skLine = oSketch.AddByProjectingEntity(oEdge)
	
	Dim oLineSegment1 As LineSegment2d
	oLineSegment1 = skLine.Geometry
	
    Dim startPt As Point2d
    startPt = skLine.StartSketchPoint.Geometry	
	
    Dim endPt As Point2d
    endPt = skLine.EndSketchPoint.Geometry	
	
    Dim startSkPt As SketchPoint
    Dim endSkPt As SketchPoint
	
	Dim oInterSectPoint As Point2d
    Dim oCircle As SketchCircle		

'start point
	'create circle
    oCircle = oSketch.SketchCircles.AddByCenterRadius(startPt, oOffset)
	
	'find intersection of circle and line
	oInterSectPoint = oLineSegment1.IntersectWithCurve(oCircle.Geometry).Item(1)
	'create point for hole
	startSkPt = oSketch.SketchPoints.Add(oInterSectPoint, True)
	
	'constrain geometry
	oCircle.Construction = True
	oSketch.DimensionConstraints.AddDiameter (oCircle, startPt ) 
	oSketch.GeometricConstraints.AddCoincident(startSkPt, skLine)
	oSketch.GeometricConstraints.AddCoincident(startSkPt, oCircle)
	oSketch.GeometricConstraints.AddCoincident _
	(skLine.StartSketchPoint, oCircle.CenterSketchPoint)	
	
	'add to hole center collection
	oHoleCenters.Add(startSkPt)
	
'end point
	'create circle
    oCircle = oSketch.SketchCircles.AddByCenterRadius(endPt, oOffset)
	
	'find intersection of circle and line
	oInterSectPoint = oLineSegment1.IntersectWithCurve(oCircle.Geometry).Item(1)
	endSkPt = oSketch.SketchPoints.Add(oInterSectPoint, True)
	
	'constrain geometry
	oCircle.Construction = True
	oSketch.DimensionConstraints.AddDiameter (oCircle, endPt ) 
	oSketch.GeometricConstraints.AddCoincident(endSkPt, skLine)
	oSketch.GeometricConstraints.AddCoincident(endSkPt, oCircle)
	oSketch.GeometricConstraints.AddCoincident _
	(skLine.EndSketchPoint, oCircle.CenterSketchPoint)
	
    'add to hole center collection
    oHoleCenters.Add(endSkPt)    

Next

End Sub

EESignature

Message 16 of 21

chrisw01a
Collaborator
Collaborator

I could not help but smile.  Smiley Very Happy

 

It works really good.

 

Have a great rest of the day.

 

Chris

Message 17 of 21

chrisw01a
Collaborator
Collaborator

Got this message with a 2 sheet dwg...

 

.zip attached.

 

Capture.PNG

0 Likes
Message 18 of 21

Curtis_Waguespack
Consultant
Consultant
Accepted solution

@chrisw01a wrote:

Got this message with a 2 sheet dwg...

 

 

 


Hi chrisw01a,

 

oops!  I forgot to activate each sheet. Smiley Embarassed

 

Try this version:

 

 

 

Sub Main
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

Dim Sheet As Inventor.Sheet
Dim oView As DrawingView
Dim oAutoCenterLines As AutomatedCenterlineSettings
Dim oNameList As New ArrayList
oNameList.Clear

Dim oCurrentSheet  As Sheet
oCurrentSheet = oDrawDoc.ActiveSheet

'iterate through the sheets
For Each oSheet In oDrawDoc.Sheets
	oSheet.Activate
	'iterate through the views
	For Each oView In oSheet.DrawingViews
		oModDoc = ActiveSheet.View(oView.Name).ModelDocument
			
		'determine if the model is a sheet metal part
		If oModDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then 
		
			'check if list contains name
			'indicating it's already been processed
			If oNameList.Contains(oModDoc.FullFileName) Then 
				'do nothing
			Else
				'add to list
				oNameList.Add(oModDoc.FullFileName)
				'process flat pattern
				Call FlattPattern_sub(oModDoc.FullFileName)
			
			End If
			
			'set automatic center line settings
			oView.GetAutomatedCenterlineSettings(oAutoCenterLines)
				oAutoCenterLines.ApplyToHoles = True
				oAutoCenterLines.ApplyToPunches = True
				
			'get automatic center lines	
			oView.SetAutomatedCenterlineSettings(oAutoCenterLines)				
			
		End If
	Next
Next

oCurrentSheet.Activate

End Sub

Sub FlattPattern_sub(oDoc As String)
'[ edit these variables as needed
sSketchName = "Flat Pattern Sketch"
sHoleName = "Locator Holes"
oOffset = 0.1 'defines offset from edge of flat pattern
oDiameter = 0.125 'defines hole diameter
']	

'open the sheet metal part file
oPartDoc = ThisApplication.Documents.Open(oDoc, True) 


'verify document type is sheet metal
If oPartDoc.ComponentDefinition.Type <> 150995200 Then
	MessageBox.Show("File is not a sheet metal part.", "iLogic")
	Exit Sub
End If

Dim oCompDef As SheetMetalComponentDefinition
oCompDef = oPartDoc.ComponentDefinition

' Check to make sure a flat pattern is open.
If Not TypeOf ThisApplication.ActiveEditObject Is FlatPattern Then
	Try
		If oCompDef.HasFlatPattern = False Then
			oCompDef.Unfold
		Else
			oCompDef.FlatPattern.Edit
		End If
	Catch
		MessageBox.Show("Error editting the flat pattern.", "iLogic")

	End Try
End If

'  a reference to the active flat pattern.
Dim oFlatPattern As FlatPattern
oFlatPattern = ThisApplication.ActiveEditObject

'clean up existing holes
Dim oHole As HoleFeature
For Each oHole In oFlatPattern.Features.HoleFeatures
	oHole.Delete
Next
 
Dim oFace As Face
oFace = oFlatPattern.TopFace

Dim oSketch As PlanarSketch

'clean up existing sketch
For Each oSketch In oFlatPattern.Sketches
	If oSketch.Name = sSketchName Then
		oSketch.Delete
	End If
Next

' Create a new sketch.  
' the Second argument specifies To include/Not include
' the edges of the face in the sketch.
oSketch = oFlatPattern.Sketches.Add(oFace, False)

' Change the name.
oSketch.Name = sSketchName
	
'Dim oPoint As Point2d
Dim oSketchPoint As SketchPoint
oOffset = oOffset * 2.5400013716 'converts cm to inches

Dim oEdges As Edges

' Create a new object collection for the hole center points.
oHoleCenters = ThisApplication.TransientObjects.CreateObjectCollection

' Get all Bend UP edges
'where true = top face
oEdges = _
oFlatPattern.GetEdgesOfType( _
FlatPatternEdgeTypeEnum.kBendUpFlatPatternEdge, True) 

'process the Bend Edges
Call Create_SketchPoints(oSketch, oEdges, oHoleCenters, oOffset)

' Get all Bend Down edges
'where true = top face
oEdges = _
oFlatPattern.GetEdgesOfType( _
FlatPatternEdgeTypeEnum.kBendDownFlatPatternEdge, True) 

'process the Bend Edges
Call Create_SketchPoints(oSketch, oEdges, oHoleCenters, oOffset )

' Create the hole feature
oHole =  oFlatPattern.Features.HoleFeatures.AddDrilledByThroughAllExtent( _
		oHoleCenters, oDiameter * 2.5400013716 , kPositiveExtentDirection)

oHole.Name = sHoleName

oCompDef.FlatPattern.ExitEdit
oPartDoc.Save
oPartDoc.Close
End Sub

Sub Create_SketchPoints _
(oSketch As Sketch, oEdges As Edges, _
oHoleCenters As ObjectCollection, oOffset As Double)

    ' Set a reference to the transient geometry object.
    Dim oTransGeom As TransientGeometry
    oTransGeom = ThisApplication.TransientGeometry


For Each oEdge In oEdges

	'create line
    Dim skLine As SketchLine 
	skLine = oSketch.AddByProjectingEntity(oEdge)
	
	Dim oLineSegment1 As LineSegment2d
	oLineSegment1 = skLine.Geometry
	
    Dim startPt As Point2d
    startPt = skLine.StartSketchPoint.Geometry	
	
    Dim endPt As Point2d
    endPt = skLine.EndSketchPoint.Geometry	
	
    Dim startSkPt As SketchPoint
    Dim endSkPt As SketchPoint
	
	Dim oInterSectPoint As Point2d
    Dim oCircle As SketchCircle		

'start point
	'create circle
    oCircle = oSketch.SketchCircles.AddByCenterRadius(startPt, oOffset)
	
	'find intersection of circle and line
	oInterSectPoint = oLineSegment1.IntersectWithCurve(oCircle.Geometry).Item(1)
	'create point for hole
	startSkPt = oSketch.SketchPoints.Add(oInterSectPoint, True)
	
	'constrain geometry
	oCircle.Construction = True
	oSketch.DimensionConstraints.AddDiameter (oCircle, startPt ) 
	oSketch.GeometricConstraints.AddCoincident(startSkPt, skLine)
	oSketch.GeometricConstraints.AddCoincident(startSkPt, oCircle)
	oSketch.GeometricConstraints.AddCoincident _
	(skLine.StartSketchPoint, oCircle.CenterSketchPoint)	
	
	'add to hole center collection
	oHoleCenters.Add(startSkPt)
	
'end point
	'create circle
    oCircle = oSketch.SketchCircles.AddByCenterRadius(endPt, oOffset)
	
	'find intersection of circle and line
	oInterSectPoint = oLineSegment1.IntersectWithCurve(oCircle.Geometry).Item(1)
	endSkPt = oSketch.SketchPoints.Add(oInterSectPoint, True)
	
	'constrain geometry
	oCircle.Construction = True
	oSketch.DimensionConstraints.AddDiameter (oCircle, endPt ) 
	oSketch.GeometricConstraints.AddCoincident(endSkPt, skLine)
	oSketch.GeometricConstraints.AddCoincident(endSkPt, oCircle)
	oSketch.GeometricConstraints.AddCoincident _
	(skLine.EndSketchPoint, oCircle.CenterSketchPoint)
	
    'add to hole center collection
    oHoleCenters.Add(endSkPt)    

Next

End Sub

 

 

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

EESignature

Message 19 of 21

chrisw01a
Collaborator
Collaborator

That did the trick.

 

Any reason I would receive this message with multiple instances of Inventor running?

 

As soon as I closed my other Inventor, it worked fine...

 

I cannot seem to recreate it either.  It happened 2 other times this morning and I was in a hurry so I just went on.

 

This was just the original hole code, not the drawing version.

 

By the way, I'm sure you have better things to do so no worries if you don't get to looking at it.

 

 

Capture.PNG

0 Likes
Message 20 of 21

Anonymous
Not applicable

This is a great code!

 

Is there a way to offset the points? and possibly draw a line between them? I am trying to make it easier to make scribe lines on our flat patterns.

0 Likes