iLogic, update designer iProperty on save as

iLogic, update designer iProperty on save as

b.ziegler
Enthusiast Enthusiast
660 Views
7 Replies
Message 1 of 8

iLogic, update designer iProperty on save as

b.ziegler
Enthusiast
Enthusiast

is there a way without using vault to have the "Designer" iProperty update on a save as?

 

We don't use vault, so any solution involving vault is a non-starter.  We often reuse parts and assemblies from previous projects with only minor changes to them.  When the part is saved it is left with the original designer on the part even though that person may no longer work here or is not involved in the current project.  This has caused a bit of confusion with the guys in the shop who are unsure which engineer to go to with any questions.  We don't want the Designer to update on any save just the initial save as or save and replace function.

 

Thank you

0 Likes
Accepted solutions (1)
661 Views
7 Replies
Replies (7)
Message 2 of 8

dalton98
Collaborator
Collaborator

The easiest way I can think of is to mass change the "Designer" property for ever part in the assembly or folder. I dont think it is possible to track a "Save As" unless the save as is done through iLogic.

Here is an example in the assembly environment, let me know if its not what your wanting.

oDesigner = InputBox("Enter Designer Name", "Designer")

Dim oAss As AssemblyDocument = ThisApplication.ActiveDocument
oAss.PropertySets.Item(3).Item("Designer").Value = oDesigner

Dim oRefDoc As Document
For Each oRefDoc In oAss.AllReferencedDocuments
	Try
	oRefDoc.PropertySets.Item(3).Item("Designer").Value = oDesigner
	Catch
	End Try
Next
0 Likes
Message 3 of 8

b.ziegler
Enthusiast
Enthusiast

Thank you for this I appreciate it though this doesn't quite do quite what I'm looking for.  This code will change the designer on all of the parts including those that are being used as is and don't need the iProperty updated.  Sorry that I wasn't clearer with what I'm looking for.

 

you did mention that it might be doable if we used iLogic as the save as, would doing it this way also work when using the save and replace command?

 

0 Likes
Message 4 of 8

dalton98
Collaborator
Collaborator

Are all the parts you want the designer name changed in the same folder? If so you could try this.

Dim FileLocation As System.IO.DirectoryInfo = _
New System.IO.DirectoryInfo("Z:\D\Equipment\temp\")

For Each oFile In FileLocation.GetFiles()
	Dim oDoc As Document
	oDoc = ThisApplication.Documents.Open(oFile.FullName, False)
	oDoc.PropertySets.Item(3).Item("Designer").Value = "DDP"
	oDoc.Save
	oDoc.Close
Next  

 

0 Likes
Message 5 of 8

dalton98
Collaborator
Collaborator

And the codeable option would look something like this:

1. select all the parts you want to replace

2. save as all selected parts to new folder

3. change designer of all new parts

4. replace all of the selected parts with newly created ones

0 Likes
Message 6 of 8

b.ziegler
Enthusiast
Enthusiast

We are getting closer to something that works and that is simple enough that people will actually use it.  So I took your most recent bit of code here, added a little from your first bit and some code from another script we use and it looks like this:

 

oDesigner = InputBox("Enter Designer Name", "Designer")

oPath = ThisDoc.Path
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
Dim oExportCount As Integer
oExportCount = 0

' Folder Location
Dim oDialog As New FolderBrowserDialog
oDialog.Description = "Select directory to update"
oDialog.RootFolder = System.Environment.SpecialFolder.MyComputer
oDialog.SelectedPath = oPath
Dim oRes As DialogResult = oDialog.ShowDialog()
If oRes = DialogResult.OK Then
	oFolder = oDialog.SelectedPath
Else
	MessageBox.Show("No folder selected!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
	Exit Sub
End If

For Each oFile In oFolder 'FileLocation.GetFiles()
	Dim oDoc As Document
	oDoc = ThisApplication.Documents.Open(oFile.FullName, False)
	oDoc.PropertySets.Item(3).Item("Designer").Value = oDesigner
	oDoc.Save
	oDoc.Close
Next 


So this code asks the engineer to input their name, then it asks for the directory of parts to update.  Those two parts work well, but I get an error on line  26:

"Error on line 26 in rule: test, in document: x.iam

Public member 'FullName' on type 'Char' not found."

 

line 26 is : 

oDoc = ThisApplication.Documents.Open(oFile.FullName, False)

 

I do not know enough about coding to know how to troubleshoot this

 

0 Likes
Message 7 of 8

dalton98
Collaborator
Collaborator
Accepted solution

Good morning. You need to add this:

Dim FileLocation As System.IO.DirectoryInfo = _
New System.IO.DirectoryInfo(oFolder)

 For each oFile in FileLocation.GetFiles()
Try
''''
Catch
End Try
Next

Also added a try/catch in case you get any errors with the files.

Also you should add a 'Return' for when no folder is selected so it leaves the code without throwing an error

0 Likes
Message 8 of 8

b.ziegler
Enthusiast
Enthusiast

I think we have a winner, thank you for your help with this.

 

And here is the code in case anyone else reading this thread is interested:

oDesigner = InputBox("Enter Designer Name", "Designer")

oPath = ThisDoc.Path
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
Dim oExportCount As Integer
oExportCount = 0

' Folder Location
Dim oDialog As New FolderBrowserDialog
oDialog.Description = "Select directory to update"
oDialog.RootFolder = System.Environment.SpecialFolder.MyComputer
oDialog.SelectedPath = oPath
Dim oRes As DialogResult = oDialog.ShowDialog()
If oRes = DialogResult.OK Then
	oFolder = oDialog.SelectedPath
Else
	MessageBox.Show("No folder selected!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
	Exit Sub
End If

Dim FileLocation As System.IO.DirectoryInfo = _
New System.IO.DirectoryInfo(oFolder)

For Each oFile In FileLocation.GetFiles()
	Try
	Dim oDoc As Document
	oDoc = ThisApplication.Documents.Open(oFile.FullName, False)
	oDoc.PropertySets.Item(3).Item("Designer").Value = oDesigner
	oDoc.Save
	oDoc.Close
	Catch
	End Try
Next 
0 Likes