Change length of a content center file with ilogic.

Change length of a content center file with ilogic.

gma
Advocate Advocate
2,300 Views
11 Replies
Message 1 of 12

Change length of a content center file with ilogic.

gma
Advocate
Advocate

Hi,

 

I need some help to change a lenght on a content center file with an ilogic code.

I have two legs with a cross tube between, so i have a main leg...

This cross tube is the picture below and the length of this tube depends of the width of the main leg.

F.eks 

The width of the leg assembly is 500mm, then my tube have to be 400mm...

 

Does anyoune know how it can be coded?

 

Vh

GMA

 

 

 

gma_1-1589368672595.png

 

0 Likes
Accepted solutions (1)
2,301 Views
11 Replies
Replies (11)
Message 2 of 12

JhoelForshav
Mentor
Mentor

@gma 

If you could provide some files or more information that would help.

I can't really give more of an answear than this with the information I have right now.

 

The length of a CC-member is often controlled by a parameter named "B_L",

A simple iLogic rule to change the length:

Parameter("I158251:1", "B_L") = 400
iLogicVb.UpdateWhenDone = True

B_L.PNG

0 Likes
Message 3 of 12

gma
Advocate
Advocate

It dos't work here.

I think you use a custom cc file.

I use a standard file...

 

Is it not possible to change the length of a standard file?

 

 

gma_0-1589433343367.png

 

 

 

0 Likes
Message 4 of 12

JhoelForshav
Mentor
Mentor
Accepted solution

You have to replace it then. A bit more complex but absolutely doable.

See this code. It identifies the family and row of the member and replaces it with a new standard member of that row with your B_L-value of choice 🙂

Dim oDoc As AssemblyDocument = ThisDoc.Document
Dim oDef As AssemblyComponentDefinition = oDoc.ComponentDefinition
Dim oCC As ContentCenter = ThisApplication.ContentCenter
Dim oCCmember As ComponentOccurrence = oDef.Occurrences.ItemByName("KCKR 25 x 2 - 100:1")

Dim propSet As PropertySet = oCCmember.Definition.Document.PropertySets.Item("{B9600981-DEE8-4547-8D7C-E525B3A1727A}")

' Get FamilyId property
Dim familyId As Inventor.Property = propSet.Item("FamilyId")

'Get Family
Dim oContentFamily As ContentFamily = oCC.GetContentObject("v3#" & familyId.Value & "#") 


' Get MemberId property
Dim strMemberId As String = propSet("MemberId").Value 

'Get Row
Dim oContentTableRow As ContentTableRow = oCC.GetContentObject("v3#" & familyId.Value & "#" & strMemberId)
'Replace member
Dim ee As MemberManagerErrorsEnum
'B_L value
Dim oNv As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap
oNv.Add("B_L", 400)
Dim oNewMember As String = oContentFamily.CreateMember(oContentTableRow, ee, "Some error occured", , False, , oNv)

oCCmember.Replace(oNewMember, False)

replaceStandard.PNG

Message 5 of 12

gma
Advocate
Advocate

Perfect, it's working...

 

Thank you very much...

 

Regards

Gøsta.

Message 6 of 12

denis.semeniuc
Advocate
Advocate

Hi, 

Good job, is it possible to add in the code the possibility of changing the diameter of pipe.

Thank you.

0 Likes
Message 7 of 12

A.Acheson
Mentor
Mentor

Here is a method to do it. You can change the criteria of row selection to whatever make sense. For Pipe ND and SN are straight forwarded, basically anything that is a key in your CC dialog. 

Dim oDoc As AssemblyDocument = ThisDoc.Document
Dim oDef As AssemblyComponentDefinition = oDoc.ComponentDefinition
Dim oCC As ContentCenter = ThisApplication.ContentCenter

Dim oCCmember As ComponentOccurrence = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Select a component to add to the folder, Press Esc when Complete") 	

Dim NDList As String() = {"2", "3", "4", "5", "6" }
Dim ND As String = InputListBox("Choose a ND", NDList, "2", Title := "Change Pipe ND", ListName := "PIPE ND")
If ND = Nothing Then Return	

Dim PL As String = InputBox("Enter a Length in inches", "PL", "600")

Dim propSet As PropertySet = oCCmember.Definition.Document.PropertySets.Item("{B9600981-DEE8-4547-8D7C-E525B3A1727A}")

'Get FamilyId property.
Dim familyId As Inventor.Property = propSet.Item("FamilyId")

'Get Family.
Dim oContentFamily As ContentFamily = oCC.GetContentObject("v3#" & familyId.Value & "#") 

' Get MemberId property
Dim strMemberId As String = propSet("MemberId").Value 

'Get Current Row
Dim oCurrentTableRow As ContentTableRow = oCC.GetContentObject("v3#" & familyId.Value & "#" & strMemberId)

'Set the column criteria. 
Dim ND_Col As ContentTableColumn = oContentFamily.TableColumns.Item("ND")
Dim Sch_Col As ContentTableColumn = oContentFamily.TableColumns.Item("SN")

'Get current schedule or have seperate list.
Dim CurrentSch As String = oCurrentTableRow.GetCellValue(Sch_Col)

Dim oNewMember As String 

'Get Row.
Dim oContentTableRow As ContentTableRow 
For Each oContentTableRow In oContentFamily.TableRows
	
	'Set the criteria for row selection
	If oContentTableRow.GetCellValue(ND_Col) = ND AndAlso oContentTableRow.GetCellValue(Sch_Col) = CurrentSch
		'Logger.Info(oContentTableRow.Index)
		
		Dim ee As MemberManagerErrorsEnum

		'PL value.
		Dim oNv As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap
		oNv.Add("PL", PL)

		'Create Member.
		oNewMember = oContentFamily.CreateMember(oContentTableRow, ee, "Some error occured", , False, , oNv)
		
		'Replace member.
		oCCmember.Replace(oNewMember, False)

 	End If
Next



If  String.IsNullOrEmpty(oNewMember) Then
	MessageBox.Show("No matching row found", "Title")
End If

oDoc.Update
If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 8 of 12

denis.semeniuc
Advocate
Advocate

It works very well. thank you. I have another problem: see photo. I have a plate where the diameter and thickness change. I tried to apply the same rule with adaptation and it does not work. can you help me plizz.

0 Likes
Message 9 of 12

A.Acheson
Mentor
Mentor

Fairly simple just change "ND" for "Diameter" and "SN" for "Thickness". You need to ensure the Column name used is the system name and not the display name. At least from what I can remember. 

AAcheson_0-1674510474190.png

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 10 of 12

denis.semeniuc
Advocate
Advocate

Hi,

I changed the parameters

Message"no matching row found"

 

Dim oDoc As AssemblyDocument = ThisDoc.Document
Dim oDef As AssemblyComponentDefinition = oDoc.ComponentDefinition
Dim oCC As ContentCenter = ThisApplication.ContentCenter

Dim oCCmember As ComponentOccurrence = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Select a component to add to the folder, Press Esc when Complete") 	



Dim NDList As String() = {"2", "3", "4", "5", "6" }
Dim ND As String = InputListBox("Choose a ND", NDList, "2", Title := "Change Dia", ListName := "Dia")
If ND = Nothing Then Return	

Dim PL As String = InputBox("Enter a Thk in inches", "THK", "3/16")

Dim propSet As PropertySet = oCCmember.Definition.Document.PropertySets.Item("{B9600981-DEE8-4547-8D7C-E525B3A1727A}")

'Get FamilyId property.
Dim familyId As Inventor.Property = propSet.Item("FamilyId")

'Get Family.
Dim oContentFamily As ContentFamily = oCC.GetContentObject("v3#" & familyId.Value & "#") 

' Get MemberId property
Dim strMemberId As String = propSet("MemberId").Value 

'Get Current Row
Dim oCurrentTableRow As ContentTableRow = oCC.GetContentObject("v3#" & familyId.Value & "#" & strMemberId)

'Set the column criteria. 
Dim ND_Col As ContentTableColumn = oContentFamily.TableColumns.Item("diameter")
Dim Sch_Col As ContentTableColumn = oContentFamily.TableColumns.Item("thickness")

'Get current schedule Or have seperate list.
Dim CurrentSch As String = oCurrentTableRow.GetCellValue(Sch_Col)

Dim oNewMember As String 

'Get Row.
Dim oContentTableRow As ContentTableRow 
For Each oContentTableRow In oContentFamily.TableRows
	
	'Set the criteria for row selection
	If oContentTableRow.GetCellValue(ND_Col) = ND AndAlso oContentTableRow.GetCellValue(Sch_Col) = CurrentSch
		'Logger.Info(oContentTableRow.Index)
		
		Dim ee As MemberManagerErrorsEnum

		'PL value.
		Dim oNv As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap
		oNv.Add("thickness", PL)

		'Create Member.
		oNewMember = oContentFamily.CreateMember(oContentTableRow, ee, "Some error occured", , False, , oNv)
		
		'Replace member.
		oCCmember.Replace(oNewMember, False)

 	End If
Next



If  String.IsNullOrEmpty(oNewMember) Then
	MessageBox.Show("No matching row found", "Title")
End If

oDoc.Update

 

 

0 Likes
Message 11 of 12

A.Acheson
Mentor
Mentor

Is there a custom length/thickness value required? If not this needs to be removed from member creation. Are the column labels correct to system and not display name as they are different. Spelled correctly with correct case etc? 

AAcheson_0-1674518181972.png

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 12 of 12

denis.semeniuc
Advocate
Advocate

Tahks

0 Likes