Changing Mark Style

Changing Mark Style

brianA32ZM
Advocate Advocate
457 Views
4 Replies
Message 1 of 5

Changing Mark Style

brianA32ZM
Advocate
Advocate

Hello, I am attempting to change the Style of a Mark located on a sheet metal flat pattern. The code below fails at  "oMarkDef.Style.name = "Mark Surface" and I am not sure why. Can someone help point me in the correct direction. Thank you.

 

' Create a new part document.
Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.ActiveDocument
Dim oCompDef As PartComponentDefinition
oCompDef = oPartDoc.ComponentDefinition

For Each oMarkDef In oCompDef.Flatpattern.Features.item("Etch Info").definition
	oMarkDef.Style.name = "Mark Surface"	
Next

 

 

error:

System.Runtime.InteropServices.COMException (0x80004005): Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
at Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateSet(Object o, Type& objType, String name, Object[] args, String[] paramnames, Boolean OptimisticSet, CallType UseCallType)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateSet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean OptimisticSet, Boolean RValueBase, CallType CallType)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateSetComplex(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean OptimisticSet, Boolean RValueBase)

0 Likes
Accepted solutions (1)
458 Views
4 Replies
Replies (4)
Message 2 of 5

bradeneuropeArthur
Mentor
Mentor
Could you share the files?

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 3 of 5

brianA32ZM
Advocate
Advocate

Thank you, the test file is attached.

0 Likes
Message 4 of 5

JelteDeJong
Mentor
Mentor
Accepted solution

try this:

Dim oPartDoc As PartDocument = ThisApplication.ActiveDocument
Dim oCompDef As SheetMetalComponentDefinition = oPartDoc.ComponentDefinition

oCompDef.FlatPattern.Edit()

Dim oMarkDef As MarkDefinition = oCompDef.Flatpattern.Features.item("Etch Info").definition

Dim style = oPartDoc.MarkStyles.Item("Mark Surface")

For i As Integer = 1 To oMarkDef.MarkGeometrySetCount
	oMarkDef.MarkGeometrySetItem(i).Style = style
Next

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

Message 5 of 5

brianA32ZM
Advocate
Advocate
JelteDeLong,

Thank you so much. I sent hours trying to solve that one. It is frustrating as I did find MarkGeometrySet in the programming help but could not figure out how to apply it. Thanks again!
0 Likes