Modifying an existing sketch arc using VBA

Modifying an existing sketch arc using VBA

nick.seman
Advocate Advocate
324 Views
4 Replies
Message 1 of 5

Modifying an existing sketch arc using VBA

nick.seman
Advocate
Advocate

I have the need to update an existing sketch arc via VBA.  I cannot delete and replace it as I have downstream dependencies.  I am almost able to accomplish it by constraining the start, center, and end points to sketch points (based on work points) and then programmatically modifying the locations of the work points - which works except when the curve direction of the arc (left or right) flips.

 

While I am able to harvest all the information about the existing arc using "SketchArc" I do not see any way to update the definition.

 

Can anyone provide any ideas or direction on this?

 

Thanks;

Nickl

0 Likes
325 Views
4 Replies
Replies (4)
Message 2 of 5

JelteDeJong
Mentor
Mentor

The properties of an arc seem to be read-only so that means there is no way to change an arc. But you can create a new arc (using the properies of the old arc.) and then delete the old arc.

 

the fuction to create an arc has a optional (boolean) paramater to tell Inventor to draw the arc clock or counter clock wise. In the following example I draw 2 arcs. the first is clockwise and the other countercockwise. Notice the boolean at the end of line 6 and 7.

 

Dim otg = ThisApplication.TransientGeometry
Dim doc As PartDocument = ThisDoc.Document

Dim sketch As Sketch = doc.ComponentDefinition.Sketches.Add(doc.ComponentDefinition.WorkPlanes.Item(1))
sketch.Edit()
Dim arc1 = sketch.SketchArcs.AddByCenterStartEndPoint(otg.CreatePoint2d(0, 0), otg.CreatePoint2d(10, 0), otg.CreatePoint2d(0, 10), True)
Dim arc2 = sketch.SketchArcs.AddByCenterStartEndPoint(otg.CreatePoint2d(-1, -1), otg.CreatePoint2d(9, -1), otg.CreatePoint2d(-1, 9), False)

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 3 of 5

nick.seman
Advocate
Advocate

That is pretty much what I had arrived at as well.   Problem is that it breaks my downstream processes if I create a new arc and delete the exisitng.  I think I might be able to change my approach to manipulating the work points' locations that the existing arc follows.

 

Thanks for looking at it for me.

 

Nick

0 Likes
Message 4 of 5

bradeneuropeArthur
Mentor
Mentor

Could you demonstrate with maybe pictures what you try to modify?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 5 of 5

JelteDeJong
Mentor
Mentor

Moving the arc by manipulating the sketch points seems possible:

Dim otg = ThisApplication.TransientGeometry
Dim doc As PartDocument = ThisDoc.Document

Dim sketch As Sketch = doc.ComponentDefinition.Sketches.Add(doc.ComponentDefinition.WorkPlanes.Item(1))
sketch.Edit()
Dim arc1 = sketch.SketchArcs.AddByCenterStartEndPoint(otg.CreatePoint2d(0, 0), otg.CreatePoint2d(10, 0), otg.CreatePoint2d(0, 10), True)
Dim arc2 = sketch.SketchArcs.AddByCenterStartEndPoint(otg.CreatePoint2d(-1, -1), otg.CreatePoint2d(9, -1), otg.CreatePoint2d(-1, 9), False)

MsgBox("Now move.")
arc1.CenterSketchPoint.MoveTo(otg.CreatePoint2d(1, 1))
arc1.StartSketchPoint.MoveTo(otg.CreatePoint2d(11, 1))
arc1.EndSketchPoint.MoveTo(otg.CreatePoint2d(1, 11))

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes