Inventor General Discussion

Reply
Contributor
paul.huppertz
Posts: 11
Registered: ‎09-17-2013
Message 1 of 10 (564 Views)

iLogic increment revision Letter

564 Views, 9 Replies
11-20-2013 01:19 AM

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.

Distinguished Contributor
ad64
Posts: 137
Registered: ‎11-03-2006
Message 2 of 10 (506 Views)

Re: iLogic increment revision Letter

11-20-2013 06:21 AM in reply to: paul.huppertz
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
Distinguished Mentor
pcrawley
Posts: 677
Registered: ‎05-23-2002
Message 3 of 10 (478 Views)

Re: iLogic increment revision Letter

11-20-2013 02:45 PM in reply to: paul.huppertz

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
Distinguished Mentor
pcrawley
Posts: 677
Registered: ‎05-23-2002
Message 4 of 10 (465 Views)

Re: iLogic increment revision Letter

11-20-2013 06:15 PM in reply to: paul.huppertz

 

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
Valued Mentor
jcneal
Posts: 324
Registered: ‎04-10-2010
Message 5 of 10 (441 Views)

Re: iLogic increment revision Letter

11-21-2013 06:55 AM 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 2014
Autodesk Product Design Suite Standard 2013
Microsoft Office 2007 & 2013
Windows 7 64bit
Synergis Adept 2013
Visual Studio Express 2010
Contributor
paul.huppertz
Posts: 11
Registered: ‎09-17-2013
Message 6 of 10 (433 Views)

Re: iLogic increment revision Letter

11-21-2013 07:52 AM 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 

 

Distinguished Mentor
pcrawley
Posts: 677
Registered: ‎05-23-2002
Message 7 of 10 (421 Views)

Re: iLogic increment revision Letter

11-21-2013 08:49 AM in reply to: jcneal
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
Valued Mentor
jcneal
Posts: 324
Registered: ‎04-10-2010
Message 8 of 10 (416 Views)

Re: iLogic increment revision Letter

11-21-2013 09:31 AM 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 2014
Autodesk Product Design Suite Standard 2013
Microsoft Office 2007 & 2013
Windows 7 64bit
Synergis Adept 2013
Visual Studio Express 2010
Distinguished Mentor
pcrawley
Posts: 677
Registered: ‎05-23-2002
Message 9 of 10 (404 Views)

Re: iLogic increment revision Letter

11-21-2013 11:07 AM in reply to: paul.huppertz
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
Valued Mentor
jcneal
Posts: 324
Registered: ‎04-10-2010
Message 10 of 10 (389 Views)

Re: iLogic increment revision Letter

11-21-2013 01:16 PM in reply to: pcrawley
HI,

solved.

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

thanks again
Autodesk Inventor Professional 2014
Autodesk Product Design Suite Standard 2013
Microsoft Office 2007 & 2013
Windows 7 64bit
Synergis Adept 2013
Visual Studio Express 2010

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube