Dynamic sketch with array in .idw

Dynamic sketch with array in .idw

S7RM7RPR
Advocate Advocate
379 Views
2 Replies
Message 1 of 3

Dynamic sketch with array in .idw

S7RM7RPR
Advocate
Advocate

I'm not expecting anyone to have a solution but on the off chance that someone has an idea.. I've actually managed to dig into the API and even figured out how to edit an existing sketch AND how to find all the sketch dimensions on my own, but I'm stumped now.

 

I am attempting to set up a dynamic sketch in an .idw that I can update via iLogic. I am using the below code to be able to update sketch constraints, however I've discovered that it can't find the parameter used to define the quantity in an array - in my case d20. It find everything except for array parameters which tells me that either I flat out can't access it because .idw sketches are ridiculous, or I'm using the wrong property. However I can't find a property that does work..

 

I'd appreciate it if you can even just suggest how I might be able to have a dynamic array in a idw sketch. It's looking to me like it's not possible. My last resort is going to be to draw out each variation manually and use layers..

 

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oSketch As DrawingSketch

For Each oSketch In oDrawDoc.ActiveSheet.Sketches
	If oSketch.Name = "Sketch1"
		oSketch.Edit
		
		For Each constraintX In oSketch.DimensionConstraints
			Dim paramX = constraintX.Parameter
			MsgBox(paramX.Name)
			If paramX.Name = "d20"
				paramX._Value = Parameter.Param("MtgQty")._Value
			End If
		Next

		oSketch.Solve()
		oSketch.ExitEdit()

		Exit For
	End If
Next

 

 

 

0 Likes
380 Views
2 Replies
Replies (2)
Message 2 of 3

bradeneuropeArthur
Mentor
Mentor

 

 

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oSketch As DrawingSketch

For Each oSketch In oDrawDoc.ActiveSheet.Sketches
	If oSketch.Name = "Sketch1"
		oSketch.Edit
		
		Dim a As Application = ThisApplication
		Dim b As DrawingDocument = a.ActiveDocument
		Dim c As Inventor.Parameter 

		Dim d As Inventor.DrawingSketch = b.ActiveSheet.Sketches.Item(1)

		For Each dc As Inventor.DimensionConstraint In d.DimensionConstraints
	
If dc.Parameter.Name= "d20" Then
dc.Parameter.Expression = b.Parameters.Item("MtgQty").Expression
End If
Next

		oSketch.Solve()
		oSketch.ExitEdit()

		Exit For
	End If
Next

 

 

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 3

S7RM7RPR
Advocate
Advocate

So that code is actually the same but you've got a new 'c' declaration that doesn't appear to be used anywhere..

 

I'm not sure Inventor.Parameter is going to get me anything though unless the sketch parameters are just hidden but each sketch has it's own parameter set so we have to tie the parameters to the sketch...

0 Likes