Part won't update after rule runs, after ipart member change

Part won't update after rule runs, after ipart member change

SharkDesign
Mentor Mentor
1,666 Views
24 Replies
Message 1 of 25

Part won't update after rule runs, after ipart member change

SharkDesign
Mentor
Mentor

I have an ilogic rule that spaces the holes out on a linear rail. 

Everything works perfectly until I convert it to iPart. I need to do this for content centre. 

When I change between factory members, the rule runs (I put a message box in to prove it) But the part doesn't update afterwards, despite using 

iLogicVb.UpdateWhenDone = True

Any ideas?

This is the abridged version

Parameter.UpdateAfterChange = True

If Size = "HGR15" Then
HoleCB = "7.5"
etc etc.......
BlindThreadDepth = 8

Else If Size = "HGR20" Then
etc etc................

End If
iLogicVb.UpdateWhenDone = True
ThisApplication.ActiveView.Fit

Inventor 2018

  Inventor Certified Professional
0 Likes
Accepted solutions (1)
1,667 Views
24 Replies
Replies (24)
Message 2 of 25

JamieVJohnson2
Collaborator
Collaborator

try the update (and/or Update2(accept errors = true/false)) command on the PartDocument class:

Dim partDoc As PartDocument = ThisDoc.Document
partDoc.Update

Jamie Johnson : Owner / Sisu Lissom, LLC https://sisulissom.com/
0 Likes
Message 3 of 25

SharkDesign
Mentor
Mentor

Sorry I don't know how to do this, is there a link to the method?

 

Thanks

James

  Inventor Certified Professional
0 Likes
Message 4 of 25

chandra.shekar.g
Autodesk Support
Autodesk Support

@SharkDesign,

 

@JamieVJohnson2 - saying that modify the code like below.

 

Parameter.UpdateAfterChange = True

If Size = "HGR15" Then
HoleCB = "7.5"
etc etc.......
BlindThreadDepth = 8

Else If Size = "HGR20" Then
etc etc................

End If

Dim partDoc As PartDocument = ThisDoc.Document
partDoc.Update iLogicVb.UpdateWhenDone = True ThisApplication.ActiveView.Fit

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 5 of 25

SharkDesign
Mentor
Mentor

I thought that was what you meant, I did that and it didn't work. 

  Inventor Certified Professional
0 Likes
Message 6 of 25

chandra.shekar.g
Autodesk Support
Autodesk Support

@SharkDesign,

 

Can you please provide non confidential data to test the behavior?

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 7 of 25

SharkDesign
Mentor
Mentor

Yes, can I email it to you please?

  Inventor Certified Professional
0 Likes
Message 8 of 25

chandra.shekar.g
Autodesk Support
Autodesk Support

@SharkDesign,

 

The highlighted red line below iLogic code is not allowing to change the "Size" parameter. It is reading the value from custom iProperties (Size).

 

'Parameter.UpdateAfterChange = True
'Size = iProperties.Value("Custom", "Series")

'If Feature.IsActive("Thru hole") = True Then
'	HoleType = "Thru"
'Else If Feature.IsActive("Blind Hole") = True Then
'	HoleType = "Blind"
'End if

'Extrusion selector

Size = iProperties.Value("Custom", "Series")

If Size = "HGR15" Then
'Feature.IsActive("HGR15") = True
'Feature.IsActive("HGR20") = False
'Feature.IsActive("HGR25") = False
'Feature.IsActive("HGR30") = False
'Feature.IsActive("HGR35") = False
'Feature.IsActive("HGR45") = False
'Feature.IsActive("HGR55") = False
'Feature.IsActive("HGR65") = False
HoleCB = "7.5"
CBdepth = "5.3"
HoleW = "4.5"
Pitch = "60"
Evalue = "6"
HoleHi = "15"
BlindTheadDes = "M5x0.8"
BlindThreadDepth = 8

Else If Size = "HGR20" Then
'Feature.IsActive("HGR15") = False
'Feature.IsActive("HGR20") = True
'Feature.IsActive("HGR25") = False
'Feature.IsActive("HGR30") = False
'Feature.IsActive("HGR35") = False
'Feature.IsActive("HGR45") = False
'Feature.IsActive("HGR55") = False
'Feature.IsActive("HGR65") = False
HoleCB = "9.5"
CBdepth = "5.3"
HoleW = "4.5"
Pitch = "60"
Evalue = "7"
HoleHi = "17.5"
BlindTheadDes = "M6x1"
BlindThreadDepth = 10

Else If Size = "HGR25" Then
'Feature.IsActive("HGR15") = False
'Feature.IsActive("HGR20") = False
'Feature.IsActive("HGR25") = True
'Feature.IsActive("HGR30") = False
'Feature.IsActive("HGR35") = False
'Feature.IsActive("HGR45") = False
'Feature.IsActive("HGR55") = False
'Feature.IsActive("HGR65") = False
HoleCB = "11"
CBdepth = "9"
HoleW = "7"
Pitch = "60"
Evalue = "8"
HoleHi = "22"
BlindTheadDes = "M6x1"
BlindThreadDepth = 12

Else If Size = "HGR30" Then
'Feature.IsActive("HGR15") = False
'Feature.IsActive("HGR20") = False
'Feature.IsActive("HGR25") = False
'Feature.IsActive("HGR30") = True
'Feature.IsActive("HGR35") = False
'Feature.IsActive("HGR45") = False
'Feature.IsActive("HGR55") = False
'Feature.IsActive("HGR65") = False
HoleCB = "14"
CBdepth = "12"
HoleW = "9"
Pitch = "80"
Evalue = "9"
HoleHi = "26"
BlindTheadDes = "M8x1.25"
BlindThreadDepth = 15

Else If Size = "HGR35" Then
'Feature.IsActive("HGR15") = False
'Feature.IsActive("HGR20") = False
'Feature.IsActive("HGR25") = False
'Feature.IsActive("HGR30") = False
'Feature.IsActive("HGR35") = True
'Feature.IsActive("HGR45") = False
'Feature.IsActive("HGR55") = False
'Feature.IsActive("HGR65") = False
HoleCB = "14"
CBdepth = "12"
HoleW = "9"
Pitch = "80"
Evalue = "9"
HoleHi = "29"
BlindTheadDes = "M8x1.25"
BlindThreadDepth = 17

Else If Size = "HGR45" Then
'Feature.IsActive("HGR15") = False
'Feature.IsActive("HGR20") = False
'Feature.IsActive("HGR25") = False
'Feature.IsActive("HGR30") = False
'Feature.IsActive("HGR35") = False
'Feature.IsActive("HGR45") = True
'Feature.IsActive("HGR55") = False
'Feature.IsActive("HGR65") = False
HoleCB = "20"
CBdepth = "17"
HoleW = "14"
Pitch = "105"
Evalue = "12"
HoleHi = "38.1"
BlindTheadDes = "M12x1.75"
BlindThreadDepth = 24

Else If Size = "HGR55" Then
'Feature.IsActive("HGR15") = False
'Feature.IsActive("HGR20") = False
'Feature.IsActive("HGR25") = False
'Feature.IsActive("HGR30") = False
'Feature.IsActive("HGR35") = False
'Feature.IsActive("HGR45") = False
'Feature.IsActive("HGR55") = True
'Feature.IsActive("HGR65") = False
HoleCB = "23"
CBdepth = "20"
HoleW = "16"
Pitch = "120"
Evalue = "14"
HoleHi = "44"
BlindTheadDes = "M14x2"
BlindThreadDepth = 24


Else If Size = "HGR65" Then
'Feature.IsActive("HGR15") = False
'Feature.IsActive("HGR20") = False
'Feature.IsActive("HGR25") = False
'Feature.IsActive("HGR30") = False
'Feature.IsActive("HGR35") = False
'Feature.IsActive("HGR45") = False
'Feature.IsActive("HGR55") = False
'Feature.IsActive("HGR65") = True
HoleCB = "26"
CBdepth = "22"
HoleW = "18"
Pitch = "150"
Evalue = "15"
HoleHi = "53"
BlindTheadDes = "M20x2.5"
BlindThreadDepth = 30

End If


'Hole placement

NumHoles = Ceil(L/Pitch)
EndHole = (L - ((NumHoles - 1) * Pitch)) / 2
FirstPitch = (L/2)-EndHole


If EndHole < Evalue Then
OldNumHoles = NumHoles
NumHoles = OldNumHoles - 1
EndHole = (L - ((NumHoles - 1) * Pitch)) / 2
FirstPitch = (L/2)-EndHole
End If

'Hole Type
If HoleType = "Thru" Then
Feature.IsActive("Thru hole") = True
Feature.IsActive("Blind Hole") = False
Else If HoleType = "Blind" Then
Feature.IsActive("Thru hole") = False
Feature.IsActive("Blind Hole") = True
Feature.ThreadDesignation("Blind Hole") = BlindTheadDes
End If


'Update Part Number
If HoleType = "Thru" Then
HT="R"
Else If HoleType = "Blind" Then
HT="T"
End If
HG=Size

'iProperties.Value("Project", "Part Number")= HG & HT & L & C
'iProperties.Value("Project", "Description")= HG & " Linear Rail"
'PartName=iProperties.Value("Project", "Part Number")
Dim partDoc As PartDocument = ThisDoc.Document
partDoc.Update
ThisApplication.ActiveView.Fit

'targetFolder="C:\Hiwin Rail\"
'If Not System.IO.Directory.Exists(targetFolder) Then
'    System.IO.Directory.CreateDirectory(targetFolder)
'End If
'ThisDoc.Document.SaveAs(targetFolder & PartName & ".ipt" , True)

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 9 of 25

SharkDesign
Mentor
Mentor

You can't have a text parameter value in an ipart table, so the idea was that assigning the 'series' from the ipart table, the parameter 'size' would then update and trigger the values in the rule. 

 

Size = iProperties.Value("Custom", "Series")

So when it goes to content center you will have the options.

 

Series

Length

Hole type

 

User selects Series which is an ipart table value

This writes the value to custom iproperties

iLogic reads this custom iproperty to the parameters 'size' and updates the rest from there. 

 

Is there anther way to do this?

  Inventor Certified Professional
0 Likes
Message 10 of 25

chandra.shekar.g
Autodesk Support
Autodesk Support

@SharkDesign,

 

Hoping that below changes may be helpful.

 

'Parameter.UpdateAfterChange = True
'Size = iProperties.Value("Custom", "Series")

'If Feature.IsActive("Thru hole") = True Then
'	HoleType = "Thru"
'Else If Feature.IsActive("Blind Hole") = True Then
'	HoleType = "Blind"
'End if

'Extrusion selector

Dim sizeValue As String 
sizeValue = iProperties.Value("Custom", "Series")

 

If sizeValue = "HGR15" Then
	Size = "HGR15"
'Feature.IsActive("HGR15") = True
'Feature.IsActive("HGR20") = False
'Feature.IsActive("HGR25") = False
'Feature.IsActive("HGR30") = False
'Feature.IsActive("HGR35") = False
'Feature.IsActive("HGR45") = False
'Feature.IsActive("HGR55") = False
'Feature.IsActive("HGR65") = False
HoleCB = "7.5"
CBdepth = "5.3"
HoleW = "4.5"
Pitch = "60"
Evalue = "6"
HoleHi = "15"
BlindTheadDes = "M5x0.8"
BlindThreadDepth = 8

Else If sizeValue = "HGR20" Then
	Size = "HGR20"
'Feature.IsActive("HGR15") = False
'Feature.IsActive("HGR20") = True
'Feature.IsActive("HGR25") = False
'Feature.IsActive("HGR30") = False
'Feature.IsActive("HGR35") = False
'Feature.IsActive("HGR45") = False
'Feature.IsActive("HGR55") = False
'Feature.IsActive("HGR65") = False
HoleCB = "9.5"
CBdepth = "5.3"
HoleW = "4.5"
Pitch = "60"
Evalue = "7"
HoleHi = "17.5"
BlindTheadDes = "M6x1"
BlindThreadDepth = 10

Else If sizeValue = "HGR25" Then
	Size = "HGR25"
'Feature.IsActive("HGR15") = False
'Feature.IsActive("HGR20") = False
'Feature.IsActive("HGR25") = True
'Feature.IsActive("HGR30") = False
'Feature.IsActive("HGR35") = False
'Feature.IsActive("HGR45") = False
'Feature.IsActive("HGR55") = False
'Feature.IsActive("HGR65") = False
HoleCB = "11"
CBdepth = "9"
HoleW = "7"
Pitch = "60"
Evalue = "8"
HoleHi = "22"
BlindTheadDes = "M6x1"
BlindThreadDepth = 12

Else If sizeValue = "HGR30" Then
	Size = "HGR30"
'Feature.IsActive("HGR15") = False
'Feature.IsActive("HGR20") = False
'Feature.IsActive("HGR25") = False
'Feature.IsActive("HGR30") = True
'Feature.IsActive("HGR35") = False
'Feature.IsActive("HGR45") = False
'Feature.IsActive("HGR55") = False
'Feature.IsActive("HGR65") = False
HoleCB = "14"
CBdepth = "12"
HoleW = "9"
Pitch = "80"
Evalue = "9"
HoleHi = "26"
BlindTheadDes = "M8x1.25"
BlindThreadDepth = 15

Else If sizeValue = "HGR35" Then
	Size = "HGR35"
'Feature.IsActive("HGR15") = False
'Feature.IsActive("HGR20") = False
'Feature.IsActive("HGR25") = False
'Feature.IsActive("HGR30") = False
'Feature.IsActive("HGR35") = True
'Feature.IsActive("HGR45") = False
'Feature.IsActive("HGR55") = False
'Feature.IsActive("HGR65") = False
HoleCB = "14"
CBdepth = "12"
HoleW = "9"
Pitch = "80"
Evalue = "9"
HoleHi = "29"
BlindTheadDes = "M8x1.25"
BlindThreadDepth = 17

Else If sizeValue = "HGR45" Then
	Size = "HGR45"
'Feature.IsActive("HGR15") = False
'Feature.IsActive("HGR20") = False
'Feature.IsActive("HGR25") = False
'Feature.IsActive("HGR30") = False
'Feature.IsActive("HGR35") = False
'Feature.IsActive("HGR45") = True
'Feature.IsActive("HGR55") = False
'Feature.IsActive("HGR65") = False
HoleCB = "20"
CBdepth = "17"
HoleW = "14"
Pitch = "105"
Evalue = "12"
HoleHi = "38.1"
BlindTheadDes = "M12x1.75"
BlindThreadDepth = 24

Else If sizeValue = "HGR55" Then
	Size = "HGR55"
'Feature.IsActive("HGR15") = False
'Feature.IsActive("HGR20") = False
'Feature.IsActive("HGR25") = False
'Feature.IsActive("HGR30") = False
'Feature.IsActive("HGR35") = False
'Feature.IsActive("HGR45") = False
'Feature.IsActive("HGR55") = True
'Feature.IsActive("HGR65") = False
HoleCB = "23"
CBdepth = "20"
HoleW = "16"
Pitch = "120"
Evalue = "14"
HoleHi = "44"
BlindTheadDes = "M14x2"
BlindThreadDepth = 24


Else If sizeValue = "HGR65" Then
	Size = "HGR65"
'Feature.IsActive("HGR15") = False
'Feature.IsActive("HGR20") = False
'Feature.IsActive("HGR25") = False
'Feature.IsActive("HGR30") = False
'Feature.IsActive("HGR35") = False
'Feature.IsActive("HGR45") = False
'Feature.IsActive("HGR55") = False
'Feature.IsActive("HGR65") = True
HoleCB = "26"
CBdepth = "22"
HoleW = "18"
Pitch = "150"
Evalue = "15"
HoleHi = "53"
BlindTheadDes = "M20x2.5"
BlindThreadDepth = 30

End If


'Hole placement

NumHoles = Ceil(L/Pitch)
EndHole = (L - ((NumHoles - 1) * Pitch)) / 2
FirstPitch = (L/2)-EndHole


If EndHole < Evalue Then
OldNumHoles = NumHoles
NumHoles = OldNumHoles - 1
EndHole = (L - ((NumHoles - 1) * Pitch)) / 2
FirstPitch = (L/2)-EndHole
End If

'Hole Type
If HoleType = "Thru" Then
Feature.IsActive("Thru hole") = True
Feature.IsActive("Blind Hole") = False
Else If HoleType = "Blind" Then
Feature.IsActive("Thru hole") = False
Feature.IsActive("Blind Hole") = True
Feature.ThreadDesignation("Blind Hole") = BlindTheadDes
End If


'Update Part Number
If HoleType = "Thru" Then
HT="R"
Else If HoleType = "Blind" Then
HT="T"
End If
HG=Size

'iProperties.Value("Project", "Part Number")= HG & HT & L & C
'iProperties.Value("Project", "Description")= HG & " Linear Rail"
'PartName=iProperties.Value("Project", "Part Number")
Dim partDoc As PartDocument = ThisDoc.Document
partDoc.Update
ThisApplication.ActiveView.Fit

'targetFolder="C:\Hiwin Rail\"
'If Not System.IO.Directory.Exists(targetFolder) Then
'    System.IO.Directory.CreateDirectory(targetFolder)
'End If
'ThisDoc.Document.SaveAs(targetFolder & PartName & ".ipt" , True)

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 11 of 25

SharkDesign
Mentor
Mentor

The extrusion suppression changes but I now have to run the 'hole placement' rule manually twice to get the holes to update.

  Inventor Certified Professional
0 Likes
Message 12 of 25

chandra.shekar.g
Autodesk Support
Autodesk Support

@SharkDesign,

 

Enable or add below line at start of iLogic code and check the same.

 

Parameter.UpdateAfterChange = True

 Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 13 of 25

SharkDesign
Mentor
Mentor

Nope, I still have to update manually twice. 

  Inventor Certified Professional
0 Likes
Message 14 of 25

HermJan.Otterman
Advisor
Advisor

can you share your file here?

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes
Message 15 of 25

SharkDesign
Mentor
Mentor

Here it is. 

When you change ipart member, it doesn't update without manually running the ilogic code.

  Inventor Certified Professional
0 Likes
Message 16 of 25

clutsa
Collaborator
Collaborator

What version of Inv are you running?

If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

0 Likes
Message 17 of 25

SharkDesign
Mentor
Mentor
2018
  Inventor Certified Professional
0 Likes
Message 18 of 25

clutsa
Collaborator
Collaborator

try setting an arbitrary variable and see if that triggers it how you think it should. Something like 

arbitraryVar = L 'or any of the parameters in your model [but you can't use Parameter("L") or it won't trigger]
If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

0 Likes
Message 19 of 25

HermJan.Otterman
Advisor
Advisor

Hello James,

 

your rule is not triggered

the "Parameter.UpdateAfterChange" apperently does noting, maybe no parameters is changed....

 

I saw in you parameters the Size parameter but it did not change either.

 

So I created a new Size_Number parameter, and added it to the iPart table as you can see in me Screencast.

then when you change the iPart member, that parameter will change.

to start the rule, enter the line "trigger = Size_Number" that will trigger the rule.

((trigger may be anything it is just a variable that changes))

 

look at my screencast: https://autode.sk/2yoFq4c

 

 

 

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes
Message 20 of 25

SharkDesign
Mentor
Mentor

Thank you, that still doesn't work though. If you look in your screencast, the update symbol is there after changing members. It won't update itself. 

 

update.PNG

  Inventor Certified Professional
0 Likes