Unspecified Error

Unspecified Error

birju.work99
Observer Observer
358 Views
5 Replies
Message 1 of 6

Unspecified Error

birju.work99
Observer
Observer

Hello Everyone,

I am trying to update my model using ilogic for length (Its the input)  1000 to 3000 mm (100 mm intervals)

Model has hole patterns and centre holes.

What I want is first check all holes are unsuppressed (For which I used For loop)

Then,

For lengths 1100,1300,1500 etc  = suppress cetre holes

For lengths 1000,1200,1400 etc = Move centre holes 50 mm further and suppress next occurrence of centre holes

 

Please check the model , youl will understand.

 

It keeps giving me unspecified error on line 11. When I open the VBA , indent the lines. It works for that length, if I chenge the length error appears again.

 

Thanks in advance.

 

 

 

0 Likes
Accepted solutions (1)
359 Views
5 Replies
Replies (5)
Message 2 of 6

dalton98
Collaborator
Collaborator

What's happening is your parameter has updated but your model hasn't. Add this at the start of your rule:

ThisDoc.Document.Update

 

0 Likes
Message 3 of 6

Andrii_Humeniuk
Advisor
Advisor
Accepted solution

Hi @birju.work99 . Please try this code:

Dim oDoc As PartDocument = ThisDoc.Document
oDoc.Update()
Dim oDef As PartComponentDefinition = oDoc.ComponentDefinition
Dim oUsParams As UserParameters = oDef.Parameters.UserParameters
Dim dInstances As Double = oUsParams("Instances").Value
Dim oPatterns As RectangularPatternFeatures
oPatterns = oDef.Features.RectangularPatternFeatures

Dim oPattern1, oPattern2 As RectangularPatternFeature
oPattern1 = oPatterns("Rectangular Pattern5")
oPattern2 = oPatterns("Rectangular Pattern6")
Dim oElements1, oElements2 As FeaturePatternElements
oElements1 = oPattern1.PatternElements
oElements2 = oPattern2.PatternElements

For i As Integer = 2 To dInstances
	oElements1(i).Suppressed = False
	oElements2(i).Suppressed = False
Next

oElements2(dInstances).Suppressed = True

If Length Mod 200 = 0 Then
	oElements1((dInstances / 2) + 1).Suppressed = True
	CentreOffset_1 = 50 mm
Else
	oElements1(Ceil(dInstances / 2)).Suppressed = True
	CentreOffset_1 = 0 mm
End If

oDoc.Update()

 

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

Message 4 of 6

birju.work99
Observer
Observer
It stops the error but model is not updating.
0 Likes
Message 5 of 6

Andrii_Humeniuk
Advisor
Advisor

Add to the end of the code before updating the document Rebuild the document.

oDoc.Rebuild()
oDoc.Update()

 

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

0 Likes
Message 6 of 6

birju.work99
Observer
Observer
Thanks Andrii. It works perfectly.
Can you please me understand what have you done ?
It looks like you define each patterns and parameters, but is this necessary every time ?
0 Likes