Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic increment revision Letter

9 REPLIES 9
Reply
Message 1 of 10
Anonymous
3211 Views, 9 Replies

iLogic increment revision Letter

Hello All,

 

At the moment we have an iLogic code in our drawing template that asks for increase revision number when pressing the save button and then autom. makes an PDF file with the REV no. in the file name etc. This is nothing specials.

 

In the past (and still) our company works with Revision Letters (A, B, C). In exisiting production molds and dies a number is engraved with the related revision letter.

You see the question ... Does anyone know how to change (or make) an iLogic rule to achieve this for revision Letters?

With numbers it's easier, all you do is "Revision no. +1 ".

 

Looking forward to your answers.

9 REPLIES 9
Message 2 of 10
ad64
in reply to: Anonymous

Here's some code that will increment letters. --Steve Private Sub Main() Dim CurrentLetter As String = InputBox("Input the Current Letter", "Current Letter", "f") Dim NextLetter As String = Chr(Asc(CurrentLetter) + 1) MsgBox("The Next Letter is " & NextLetter) End Sub
Message 3 of 10
pcrawley
in reply to: Anonymous

Try this (iLogic) code.  Hopefully you can see that the variable "RevCode" can be incremented (RevCode = RevCode + 1) to get your revision bumps.

 

RevCode = 65 'This is the ASCII character code for a capital "A"

RevLetter = Chr(RevCode) 'This retrieves the character from the code number

MessageBox.Show("Revision: " & RevLetter, "Code: " & RevCode)

 

If you are embossing this text, then create "RevLetter" as a text user parameter, then you can emboss using the RevLetter parameter.  Your code would become:

 

RevCode = Asc(RevLetter) 'This gets the ASCII character code for the letter contained in the RevLetter user parameter.

 

...and now you can do RevCode = RevCode + 1

 

RevLetter = Chr(RevCode) 'This puts the updated letter back into the RevLetter parameter so the emboss will update.

 

Peter
Message 4 of 10
pcrawley
in reply to: Anonymous

 

Actually, this is a more tidy solution:

 

  1. Create a text user parameter called "Rev" and set the value to "@" (this is the ASCII character before "A")
  2. Emboss the part using the parameter "Rev"
  3. Run the iLogic rule to up-rev the letter.

 

Rule:

 

Rev = Chr(Asc(Rev)+1)
iLogicVb.UpdateWhenDone = True

 

(You need the last line, otherwise the part won't update automatically)

 

Sample part attached if you want to play. (2014 format)

 

Peter
Message 5 of 10
skyngu
in reply to: pcrawley

I tried code below.

Rev=iProperties.Value("Project", "Revision Number")
Rev = Chr(Asc(Rev)+1)
iLogicVb.UpdateWhenDone = True
iProperties.Value("Project", "Revision Number")=Rev

it returns AscII number to iproperty instead of letter. any clue? thanks.
Autodesk Inventor Professional 2019
Message 6 of 10
Anonymous
in reply to: pcrawley

The revision letter in the part works correct thank you, I understand it.

But now I want when I run the code below in stead of Rev numbers Rev Letters.

 

At the moment I use this code for auto PDF/DXF and increment of Rev nr when you want it.

 

 

I puzzled a bit but can't get it working.

 

 

noView1=True

If (Not ThisDoc.Path="") Then
	
	noView1=False
	On Error Goto geenView
	oModelname= (IO.Path.GetFileName(ThisDrawing.Sheet("sheet:1").View("VIEW1").ModelDocument.FullFileName))
	noView1=True
	
	If Right(oModelname,3)="ipn" Then
		MessageBox.Show("Let op! Er is geen PDF/dxf gemaakt. VIEW1 mag geen ipn zijn", "Error" ,MessageBoxButtons.OK,MessageBoxIcon.Error)
		Exit Sub
	End If
		
	oStocknummer = iProperties.Value(oModelname, "Project", "Stock Number")
	oPartname= iProperties.Value(oModelname, "Project", "Part Number")
	oProjectnummer = iProperties.Value(oModelname, "Project", "Project")
	oPath = ThisDoc.Path
	oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById _
	("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
	oDocument = ThisApplication.ActiveDocument
	oContext = ThisApplication.TransientObjects.CreateTranslationContext
	oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
	oOptions = ThisApplication.TransientObjects.CreateNameValueMap
	oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
	oRevisieoud = iProperties.Value("Project", "Revision Number")
	dxfgemaakt = False
	PDFgemaakt = False
	
	oFileName = ThisDoc.FileName(False) 
	
	'revisienummer van model 0 stellen
	If iProperties.Value(oModelname, "Project", "Revision Number") = "" Then
	iProperties.Value(oModelname, "Project", "Revision Number") = 0
	End If
	
	RuleParametersOutput()


	oRevNum = iProperties.Value(oModelname,"Project", "Revision Number")
	
	If iProperties.Value("Project", "Revision Number")<iProperties.Value(oModelname, "Project", "Revision Number") Then
		question = MessageBox.Show("Revisie van Part/assembly is al opgehoogt. Revisie nogmaals ophogen?", "Revisie",MessageBoxButtons.YesNo,MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)
		
		If question = vbYes Then
		oRevNum = oRevNum + 1
		iProperties.Value("Project", "Revision Number") = oRevNum 
		iProperties.Value(oModelname, "Project", "Revision Number")= oRevNum
		End If
	Else
	
		'Revisie ophogen?
		question = MessageBox.Show("Revisie ophogen?", "Revisie",MessageBoxButtons.YesNo,MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)
		
		If question = vbYes Then
		oRevNum = oRevNum + 1
		iProperties.Value("Project", "Revision Number") = oRevNum 
		iProperties.Value(oModelname, "Project", "Revision Number")= oRevNum
		End If
	End If
	
	question = MessageBox.Show("PDF en/of dxf maken?", "PDF/dxf",MessageBoxButtons.YesNo,MessageBoxIcon.Question)
	If question = vbNo Then
		Exit Sub
	End If
	
	iProperties.Value("Project", "Revision Number") = iProperties.Value(oModelname, "Project", "Revision Number")
	
	InventorVb.DocumentUpdate()
	
	'PDF instellingen wijzigen
	If oPDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then
	oOptions.Value("All_Color_AS_Black") = 0
	oOptions.Value("Remove_Line_Weights") = 0
	oOptions.Value("Vector_Resolution") = 400
	oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
	'oOptions.Value("Custom_Begin_Sheet") = 2
	'oOptions.Value("Custom_End_Sheet") = 4
	End If
	
	
	
	'get PDF target folder path
	oFolder = oPath & "/pdf"
	
	
	'Check for the PDF folder and create it if it does not exist
	If Not System.IO.Directory.Exists(oFolder) Then
		System.IO.Directory.CreateDirectory(oFolder)
	End If
	
	oNewfilename = oFolder & "\" & oFileName & " Rev" & oRevNum & ".pdf"
	
	If oRevNum = 0 Then
		oNewfilename = oFolder & "\" & oFileName & ".pdf"
	End If
	
	'Checken of PDF al bestaat
	If My.Computer.FileSystem.FileExists(oNewfilename) Then
		question = MessageBox.Show("PDF bestaat al, overschrijven?", "iLogic Question",MessageBoxButtons.YesNo,MessageBoxIcon.Question)
		If question = vbNo Then
		MessageBox.Show("Let op! Er is geen PDF gemaakt.", "Error" ,MessageBoxButtons.OK,MessageBoxIcon.Error)
		Goto dxfMaken
		End If
	End If
	
	
	'Oude revisie verplaatsen
	If (Not oRevisieoud="") And oRevisieoud <> oRevNum And My.Computer.FileSystem.FileExists(oFolder & "\" & oFileName & " Rev" & (oRevisieoud) & ".pdf") Then
		If Not System.IO.Directory.Exists(oFolder & "\revisies") Then
			System.IO.Directory.CreateDirectory(oFolder & "\revisies")
		End If
		On Error Resume Next
		My.Computer.FileSystem.MoveFile(oFolder & "\" & oFileName & " Rev" & (oRevisieoud) & ".pdf",oFolder & "\revisies" & "\" & oFileName & " Rev" & (oRevisieoud) & ".pdf")
	End If
	
	
	If (Not oRevisieoud="") And oRevisieoud <> oRevNum And My.Computer.FileSystem.FileExists(oFolder & "\" & oFileName & ".pdf") Then
		If Not System.IO.Directory.Exists(oFolder & "\revisies") Then
			System.IO.Directory.CreateDirectory(oFolder & "\revisies")
		End If
		On Error Resume Next
		My.Computer.FileSystem.MoveFile(oFolder & "\" & oFileName & ".pdf",oFolder & "\revisies" & "\" & oFileName & ".pdf")
	End If
	
	
	'Set the PDF target file name
	oDataMedium.FileName = oNewfilename
	
	PDFerror=False
	On Error Goto handlePDFLock
		
	'Publish document
	oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
	PDFgemaakt = True
	
	PDFerror = True
	
	
	
	handlePDFLock:
	If 	PDFerror = False Then
	MessageBox.Show("PDF kon niet worden overschreven. PDF is waarschijnlijk geopend.", "Error", MessageBoxButtons.OK,MessageBoxIcon.Error)
	End If
	
	dxfMaken:
	
	
	
	
	curDoc = ThisDrawing.Sheet("sheet:1").View("VIEW1").ModelDocument
	
	If curDoc.DocumentType = kPartDocumentObject And curDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
		
		
		oDoc = ThisApplication.Documents.Open(curDoc.FullFileName, True)
		
			
		oCompDef = oDoc.ComponentDefinition
		
		
		
		If oCompDef.HasFlatPattern = False Then
			oCompDef.Unfold
		Else
			oCompDef.FlatPattern.Edit
		End If
			
		'get dxf target folder path
		oFolder = oPath & "\dxf"
		
		'Check for the dxf folder and create it if it does not exist
		If Not System.IO.Directory.Exists(oFolder) Then
			System.IO.Directory.CreateDirectory(oFolder)
		End If
		
		
		oNewfilename = oFolder & "\" & oFileName & " Rev" & oRevNum & ".dxf"
		
		
		If oRevNum = 0 Then
			oNewfilename = oFolder & "\" & oFileName & ".dxf"
		End If
		
		'Checken of dxf al bestaat
		If My.Computer.FileSystem.FileExists(oNewfilename) Then
			question = MessageBox.Show("dxf bestaat al, overschrijven?", "iLogic Question",MessageBoxButtons.YesNo,MessageBoxIcon.Question)
			If question = vbNo Then
			MessageBox.Show("Let op! Er is geen dxf gemaakt.", "Error" ,MessageBoxButtons.OK,MessageBoxIcon.Error)
			Goto oEinde
			End If
		End If
			
		'Oude revisie verplaatsen
		If (Not oRevisieoud="") And oRevisieoud <> oRevNum And My.Computer.FileSystem.FileExists(oFolder & "\" & oFileName & " Rev" & (oRevisieoud) & ".dxf") Then
		If Not System.IO.Directory.Exists(oFolder & "\revisies") Then
			System.IO.Directory.CreateDirectory(oFolder & "\revisies")
		End If
		On Error Resume Next
		My.Computer.FileSystem.MoveFile(oFolder & "\" & oFileName & " Rev" & (oRevisieoud) & ".dxf",oFolder & "\revisies" & "\" & oFileName & " Rev" & (oRevisieoud) & ".dxf")
	End If
	
	
	If (Not oRevisieoud="") And oRevisieoud <> oRevNum And My.Computer.FileSystem.FileExists(oFolder & "\" & oFileName & ".dxf") Then
		If Not System.IO.Directory.Exists(oFolder & "\revisies") Then
			System.IO.Directory.CreateDirectory(oFolder & "\revisies")
		End If
		On Error Resume Next
		My.Computer.FileSystem.MoveFile(oFolder & "\" & oFileName & ".dxf",oFolder & "\revisies" & "\" & oFileName & ".dxf")
	End If
		
		
		
			
		'Set the dxf target file name
		sOut = "FLAT PATTERN DXF?AcadVersion=R12&OuterProfileLayer=Burn&InteriorProfilesLayer=Burn&InvisibleLayers=IV_TOOL_CENTER_DOWN;IV_TOOL_CENTER;IV_ARC_CENTERS;IV_TANGENT;IV_BEND;IV_BEND_DOWN;IV_FEATURE_PROFILES;IV_FEATURE_PROFILES_DOWN;IV_ALTREP_FRONT;IV_ALTREP_BACK;IV_UNCONSUMEND_SKETCHES;IV_ROLL_TANGENT;IV_ROLL&SplineTolerance Double 0.01"
		
		dxferror=False
		On Error Goto handledxfLock
			
		'Publish document.
		oCompDef.DataIO.WriteDataToFile( sOut, oNewfilename)
		dxfgemaakt = True
		
		
		
		dxferror = True
		
	
		
		handledxfLock:
		If 	dxferror = False Then
		MessageBox.Show("dxf kon niet worden overschreven. dxf is waarschijnlijk geopend.", "Error", MessageBoxButtons.OK,MessageBoxIcon.Error)
		End If
		
		oEinde:
		ThisApplication.ActiveDocument.Close
		
	
	End If
End If

If dxfgemaakt = True And PDFgemaakt=True Then
MessageBox.Show("PDF en dxf zijn gemaakt.", "Finish", MessageBoxButtons.OK)
End If
		
If dxfgemaakt = True And PDFgemaakt=False Then
MessageBox.Show("dxf gemaakt.", "Finish", MessageBoxButtons.OK)
End If
		
If dxfgemaakt = False And PDFgemaakt=True Then
MessageBox.Show("PDF gemaakt.", "Finish", MessageBoxButtons.OK)
End If

geenView:
If 	noView1 = False Then
MessageBox.Show("Let op! Er is geen PDF/dxf gemaakt. Geen 'VIEW1' gevonden. Geef één van de aanzichten de naam 'VIEW1'", "Error", MessageBoxButtons.OK,MessageBoxIcon.Error)
End If
Exit Sub 

 

Message 7 of 10
pcrawley
in reply to: skyngu

jcneal - What was the initial value of the Revision Number iProperty? Try setting it to the "@" symbol (without the quotes). You should get an "A" after running the code.
Peter
Message 8 of 10
skyngu
in reply to: pcrawley

yes, I tried "B". I can get "C" in message box. but i see "67" in iproperties

Rev=iProperties.Value("Project", "Revision Number")
MessageBox.Show(Rev)
Rev = Chr(Asc(Rev)+1)
iLogicVb.UpdateWhenDone = True
MessageBox.Show(Rev)
iProperties.Value("Project", "Revision Number")=Rev
MessageBox.Show(iProperties.Value("Project", "Revision Number"))
Autodesk Inventor Professional 2019
Message 9 of 10
pcrawley
in reply to: Anonymous

Sorry - I'm away from a PC for 3 days... I'll take a look when I get back (unless someone else solves it first!)

Just out of curiosity, what happens if you try:
iProperties.Value("Project", "Revision Number")=chr(Rev)

I know this shouldn't work as I type, but stranger things have happened.
Peter
Message 10 of 10
skyngu
in reply to: pcrawley

HI,

solved.

iProperties.Value("Project", "Revision Number")=Format(Rev)

thanks again
Autodesk Inventor Professional 2019

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report