Offset Sketch Arc

Offset Sketch Arc

danijel.radenkovic
Collaborator Collaborator
920 Views
2 Replies
Message 1 of 3

Offset Sketch Arc

danijel.radenkovic
Collaborator
Collaborator

Hello,

I have found an example which shows how to offset an rectangle by offset using point option.

Here is a code:

 

' Create a rectangle
Dim oRectangleLines As SketchEntitiesEnumerator
Set oRectangleLines = oSketch.SketchLines.AddAsTwoPointRectangle(oTransGeom.CreatePoint2d(1, 2), oTransGeom.CreatePoint2d(5, 5))

' Create a new object collection
Dim oCollection As ObjectCollection
Set oCollection = ThisApplication.TransientObjects.CreateObjectCollection

' Add the first sketch line of the rectangle to the collection
oCollection.Add oRectangleLines.Item(1)

' Offset
Dim offsettedentities As SketchEntitiesEnumerator
Set offsettedentities = oSketch.OffsetSketchEntitiesUsingPoint(oCollection, oOriginSketchPoint.Geometry, True, True)

All that I need now is to adapt code for other type of sketch entity, for example for the arcs.

I tried with folowing code but I am getting error type missmatch.

 

Dim oArc As SketchEntitiesEnumerator 'I know this declaration makes a problem but if I declare variable as SketchArc I can't add to collection
Set oArc = oSketch.SketchArcs.AddByCenterStartEndPoint(oTransGeom.CreatePoint2d(0, 0), oTransGeom.CreatePoint2d(-5, 0), oTransGeom.CreatePoint2d(5, 0), True)

' Create a new object collection
Dim oCollection As ObjectCollection
Set oCollection = ThisApplication.TransientObjects.CreateObjectCollection

' Add the first sketch line of the rectangle to the collection
oCollection.Add oArc.Item(1)

' Offset
Dim offsettedentities As SketchEntitiesEnumerator
Set offsettedentities = oSketch.OffsetSketchEntitiesUsingPoint(oCollection, oOriginSketchPoint.Geometry, True, True)

Can someone help me with this.

Regards

Danijel

 

Inventor 2018/Windows 10 x64
If this information was helpful, please consider marking it as an Accepted Solution by using the Accept as Solution. Kudos are also gladly accepted.
0 Likes
Accepted solutions (1)
921 Views
2 Replies
Replies (2)
Message 2 of 3

ekinsb
Alumni
Alumni
Accepted solution

It is about the types.  When you create a rectangle, it's creating four lines so it returns the SketchEntitiesEnumerator, which is a collection of the four lines.  When you create an arc it creates and returns that single arc.  Here's the modified code that takes that into account.

 

Dim oArc As SketchArc
Set oArc = oSketch.SketchArcs.AddByCenterStartEndPoint(oTrans​Geom.CreatePoint2d(0, 0), oTransGeom.CreatePoint2d(-5, 0), oTransGeom.CreatePoint2d(5, 0), True)

' Create a new object collection
Dim oCollection As ObjectCollection
Set oCollection = ThisApplication.TransientObjects.CreateObjectColle​ction

' Add the first sketch line of the rectangle to the collection
oCollection.Add oArc

' Offset
Dim offsettedentities As SketchEntitiesEnumerator
Set offsettedentities = oSketch.OffsetSketchEntitiesUsingPoint

Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 3 of 3

danijel.radenkovic
Collaborator
Collaborator

Hello Mr. Brian,

Thank you for the great answer. It works perfect! Smiley Happy

 

I have also two more topics that I expect answers which will be helpfull for many users and if I move topics to the top many times, this can be ungrateful to new topics of other users cause I will push down their topics again and again.

 

I will be gratefull to someone if can give me the right answer.

 

https://forums.autodesk.com/t5/inventor-customization/delete-specific-sketch-constraint-using-vba/m-...

 

https://forums.autodesk.com/t5/inventor-customization/angular-dimension-between-two-sketch-lines/td-...

 

 

Thank you very much again.

Best regards

Danijel

Inventor 2018/Windows 10 x64
If this information was helpful, please consider marking it as an Accepted Solution by using the Accept as Solution. Kudos are also gladly accepted.
0 Likes