Problem with a iLogic part generator

Problem with a iLogic part generator

Anonymous
Not applicable
632 Views
11 Replies
Message 1 of 12

Problem with a iLogic part generator

Anonymous
Not applicable

So I have created a pipe generator program that works quite well with one glaring problem.

Unless you copy and paste the part it generates into the assembly all of the parts that you place 

default to the original one placed. 

 

To see what I mean:

1) create a new assembly 

2) Drag and drop the pipe generator file into the assembly from a file where you want all the pipes it creates to be saved

3) fill out the form and click on "Sizer" Button. (Note: 10 in doesn't work right yet)

4) repeat with a few different sized pipes

5) save and close assembly and then reopen it

6) You will have all the different parts you placed default to the first one you placed into the assembly

 

Any one know why this is happening? 

 

Thanks for any help anyone offers

 

*Pipe file is attached to this post

0 Likes
633 Views
11 Replies
Replies (11)
Message 2 of 12

clutsa
Collaborator
Collaborator

So this sounds really cool but I'm not getting anything to happen. I see no form at step 3. 

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

Anonymous
Not applicable

Can you get the form to run from the iLogic window in the part?

0 Likes
Message 4 of 12

clutsa
Collaborator
Collaborator

No, there is no form or code that I can see in iLogic. If I open the "Sch 80 PVC Pipe Generator.ipt" it derives in a part. 

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

Anonymous
Not applicable

It's there when I download and open it. 

 

It won't be available from the assembly level it is only available from the part level.

 

 

0 Likes
Message 6 of 12

clutsa
Collaborator
Collaborator

Are you in 2019?

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 7 of 12

Anonymous
Not applicable

Yup,

 

I've attached the code to this message if you want to take a look through it

 

SyntaxEditor Code Snippet

Dim O1 As Double  'Od Output
Dim W1 As Double  'Wall Thickness
Dim O2 As String  'OD input
Dim L01 As Double  'Length
Dim V01 As Double 'Socket Offset
Dim x As Integer  'Error Flag
Dim N1 As String  'Part #
Dim O3 As Double  'Nominal Pipe size in decimal

	O2  = Parameter("OD1")
	L01 = Parameter("L1")

		x = 0

'************************************************************************

	O1  = 0
	W1  = 0
	V01 = 0
	
			If O2 = "1/4 in" Then
				
				O1  = 0.54
				W1  = 0.119
				V01 = 0.625
				N1  = "PVC80 - 0025"
				O3  = 0.25 
				
			ElseIf O2 = "3/8 in" Then
				
				O1  = 0.675
				W1  = 0.126
				V01 = 0.758
				N1 = "PVC80 - 0038"
				O3 = 0.375
				
			ElseIf O2 = "1/2 in" Then
				
				O1  = 0.84
				W1  = 0.147
				V01 = 0.899
				N1 = "H010307B"
				O3 = 0.5
				
			ElseIf O2 = "3/4 in" Then
				
				O1  = 1.05
				W1  = 0.154
				V01 = 1.037
				N1 = "H010308B"
				O3 = 0.75
				
			ElseIf O2 = "1 in" Then
				
				O1  = 1.315
				W1  = 0.179
				V01 = 1.154
				N1 = "H010309B"
				O3 = 1
				
			ElseIf O2 = "1-1/4 in" Then
				
				O1  = 1.66
				W1  = 0.191
				V01 = 1.272
				N1 = "H010310B"
				O3 = 1.25
			
			ElseIf O2 = "1-1/2 in" Then
				
				O1  = 1.9
				W1  = 0.2
				V01 = 1.388
				N1 = "H010311B"
				O3 = 1.5
			
			ElseIf O2 = "2 in" Then
				
				O1  = 2.375
				W1  = 0.218
				V01 = 1.5
				N1 = "H0103012"
				O3 = 2
				
			ElseIf O2 = "2-1/2 in" Then
				
				O1  = 2.875
				W1  = 0.276
				V01 = 1.804
				N1 = "H010313B"
				O3 = 2.5
				
			ElseIf O2 = "3 in" Then
				
				O1  = 3.5
				W1  = 0.3
				V01 = 1.923
				N1 = "H010314B"
				O3 = 3
				
			ElseIf O2 = "3-1/2 in" Then
				
				O1  = 4
				W1  = .318
				V01 = 1.923
				N1 = "PVC80 - 0350"
				O3 = 3.5
			
			ElseIf O2 = "4 in" Then
				
				O1  = 4.5
				W1  = 0.337
				V01 = 2.309
				N1 = "H010316B"
				O3 = 4
				
			ElseIf O2 = "4-1/2 in" Then
				
				O1  = 5
				W1  = .355
				V01 = 2.309
				N1 = "PVC80 - 0400"
				O3 = 4.5
				
			ElseIf O2 = "5 in" Then
				
				O1  = 5.563
				W1  = 0.375
				V01 = 2.45
				N1 = "PVC80 - 0500"
				O3 = 5
				
			ElseIf O2 = "6 in" Then
				
				O1  = 6.625
				W1  = 0.5
				V01 = 3.03
				N1 = "H010318B"
				O3 = 6
				
			ElseIf O2 = "8 in" Then
				
				O1  = 8.625
				W1  = 0.5
				V01 = 4.113
				N1 = "PVC80 - 0800"
				O3 = 8
				
'			ElseIf O2 = "10 in" Then
				
'				O1  = 10.75
'				W1  = 0.594
'				V01 = 5.053
'				N1 = "PVC80 - 1000"
'				O3 = 10
				
			ElseIf O2 = "10 in" Then
				
				O1  = 10.75
				W1  = 0.594
				V01 = 5.053
				N1 = "PVC80 - 1000"
				O3 = 10
				
				
			ElseIf O2 = "12 in" Then
				
				O1  = 12.75
				W1  = 0.688
				V01 = 6.1
				N1 = "PVC80 - 1200"
				O3 = 12
				
			Else 
				
				MessageBox.Show("Error1: Program Corruption")
				x = 1
				
			End If 
		
'**********************************************************************************************
								
			
								
								If O1 = 0 Or O1 < 0 Then
									
									MessageBox.Show("Error2")
									x = 1
									
								ElseIf W1 = 0 Or W1 < 0 Then
									
									MessageBox.Show("Error3")
									x = 1
									
								End If
								

'**********************************************************************************************

						
					If x = 0 Then
						
						Parameter("OD")  = O1
						Parameter("WT")  = W1
						Parameter("OFF") = V01
						Parameter("L")   = L01 + V01
						iProperties.Value("Project", "Part Number") = N1
						iProperties.Value("Project", "Stock Number") = "Sch 80 PVC " & O3 & " x " & L01						
					
						ThisDoc.Document.Rebuild
					
					End If 
					
'**********************************************************************************************


			If x = 0 Then
				
						OldFileName = ThisDoc.FileName(True) 'with extension
				StockNumber = iProperties.Value("Project", "Stock Number") 'Get "Stock Number" from iProperties
				PartName = iProperties.Value("Summary", "Title") 'Get "Title" from iProperties
				FilePath = ThisDoc.Path & "\" 'Get the path of document
				FileFullname = FilePath & OldFileName
				If StockNumber = "" And PartName = "" Then 'Check "PartNumber" and "Title" for content
				    Return
				Else
				    NewFileName = StockNumber &  ".ipt" 'Generate new file name

				    If NewFileName <> OldFileName  Then 'Check file name for changes
						
							If Not System.IO.File.Exists(ThisDoc.Path) Then
						
								'Must be false or else part is not placed into assembly
				       			 ThisDoc.Document.SaveAs(FilePath & NewFileName, False)  
								 FileFullname = FilePath & NewFileName
								 
							End If 
				    End If 
				End If

				Dim oDoc As Document
				oDoc = ThisApplication.ActiveDocument 

				If oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
					
					Dim oDef As AssemblyComponentDefinition
					oDef = oDoc.ComponentDefinition
					
					Dim occ As ComponentOccurrence
					occ = oDef.Occurrences.Item(oDef.Occurrences.Count) 
					
					occ.Replace(FileFullname, False)
					
				End If
				
			End If

				'Code found on Autdesk forums and modified to meet needs
				'https://forums.autodesk.com/t5/inventor-customization/thisdoc-document-saveas-not-working-as-expected/td-p/7446131
				'Aug 20, 2018 (RS)
										
						
						
						
	'Written on 2019/01/04 (RS)			

 

0 Likes
Message 8 of 12

clutsa
Collaborator
Collaborator

So you have a comment that says the saveascopy parameter must be false but if I set it to true I don't get the problem you're seeing... The generator seems to remember the last used settings as you work with it but doesn't seem to save... Can you explain where the must be false comes from?

If x = 0 Then
				
				OldFileName = ThisDoc.FileName(True) 'with extension
				StockNumber = iProperties.Value("Project", "Stock Number") 'Get "Stock Number" from iProperties
				PartName = iProperties.Value("Summary", "Title") 'Get "Title" from iProperties
				FilePath = ThisDoc.Path & "\" 'Get the path of document
				FileFullname = FilePath & OldFileName
				Logger.Debug("1st FileFullName = " & FileFullname)
				If StockNumber = "" And PartName = "" Then 'Check "PartNumber" and "Title" for content
				    Return
				Else
				    NewFileName = StockNumber & "_" & ".ipt" 'Generate new file name

				    If NewFileName <> OldFileName Then 'Check file name for changes
						
						'Must be false or else part is not placed into assembly
				        ThisDoc.Document.SaveAs(FilePath & NewFileName, True)  
						FileFullname = FilePath & NewFileName
						Logger.Debug("2nd FileFullName = " & FileFullname)
				    End If 
				End If

				Dim oDoc As Document
				oDoc = ThisApplication.ActiveDocument 

				If oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
					
					Dim oDef As AssemblyComponentDefinition
					oDef = oDoc.ComponentDefinition

					Dim occ As ComponentOccurrence
					occ = oDef.Occurrences.Item(oDef.Occurrences.Count)
					Logger.Debug("occ name before" & occ.Name)
					Logger.Debug("occ refDef before = " & occ.ReferencedDocumentDescriptor.DisplayName)
					occ.Replace(FileFullname, False)
					Logger.Debug("occ name after" & occ.Name)
					Logger.Debug("occ refDef after = " & occ.ReferencedDocumentDescriptor.DisplayName)
					oDoc.Rebuild


				End If
				
			End If
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 9 of 12

Anonymous
Not applicable

It's an artifact of an older version.

 

I am not too good at cleaning up my code.

 

I still have the problem no matter the setting there though.

 

Did you change anything else that might have fixed it?

0 Likes
Message 10 of 12

clutsa
Collaborator
Collaborator

I re-downloaded the file and changed only that one line. Every time I want a new tube I re-drag the generator into the assembly and puck a new option... I click done after I make a file are you leaving your form open the whole time?

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 11 of 12

Anonymous
Not applicable

No I am not, The problem lies when you close and reopen the assembly

0 Likes
Message 12 of 12

clutsa
Collaborator
Collaborator

If I insert a part save the assembly, insert a part save the assembly, so on and so on, after I close and open the assembly everything is how I would expect. For some reason the ReferenceDocumentDiscriptor isn't updating on inserting a new Generator unless you save the assembly or save the generator as a copy. 

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