Need help to make a better code ( purge & update ) with ilogic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a good the purge og update Drawing and part and assembly.
My current code is this
Sub Main()
Dim currentDocPath2
currentDocPath2 = ""
Try
currentDocPath2 = ThisDoc.PathAndFileName(False)
Logger.Info("er gemt i " & currentDocPath)
Logger.Info("Er gemt før")
Catch
Exit Sub
End Try
Logger.Info("Se om den lægge i factory mappen", "Title")
Logger.Info("er gemt i " & Left(currentDocPath2, 40))
If Left(currentDocPath2, 40) = "C:\Working Folder\Designs\Factory Models" Then
Logger.Info("Factory model ")
Exit Sub
End If
If Left(currentDocPath2, 40) = "C:\Working Folder\Designs\Factory Assets" Then
Logger.Info("Factory Assets")
Exit Sub
Else
Logger.Info("Kør purge og Update Style")
UpdateStyle3d
PurgeStyle3d
End If
End Sub
Sub UpdateStyle3d()'Try
Logger.Info("update")
Dim oCM As CommandManager
oCM = ThisApplication.CommandManager
Dim oCD As ControlDefinitions
oCD = oCM.ControlDefinitions
Dim oUpdateStyles As ControlDefinition
oUpdateStyles = oCD.Item("PurgeStylesCmd")
oUpdateStyles.Execute2 (False)
AppActivate(ThisApplication.Caption)
'SendKeys.Send("y")
SendKeys.SendWait("y" & "{Enter}")
' SendKeys.Send("{Enter}")
ThisApplication.UserInterfaceManager.DoEvents
ThisApplication.UserInterfaceManager.DoEvents
'Catch
Logger.Info("fejl")
'End Try
End Sub
Sub PurgeStyle3d()'Try
Logger.Info("Purge")
Dim oCM As CommandManager
oCM = ThisApplication.CommandManager
Dim oCD As ControlDefinitions
oCD = oCM.ControlDefinitions
Dim oUpdateStyles As ControlDefinition
oUpdateStyles = oCD.Item("UpdateStylesCmd")
oUpdateStyles.Execute2 (False)
AppActivate(ThisApplication.Caption)
'SendKeys.Send("y")
SendKeys.SendWait("y" & "{Enter}")
' SendKeys.Send("{Enter}")
ThisApplication.UserInterfaceManager.DoEvents
ThisApplication.UserInterfaceManager.DoEvents
'Catch
Logger.Info("fejl")
'End Try
End Sub
This code have at less 2 problem .. You can´t do anything else .. or it will fail to press the yes buttom. Second when in the factory design utilties it calcel if you try to puclich an Assets.
The first code I made did not seens to have this problem , but if only wrong on drawing and only dated it . Can anyone help make a code that does not have this problem ? and both Purge and update , iam , ipt and idw ?
Dim oTargetDoc, oSourceDoc As DrawingDocument
oTargetDoc = ThisDrawing.Document
oStyles = oTargetDoc.StylesManager.Styles
For Each oStyle In oStyles
If oStyle.UpToDate = False Then
oStyle.UpdateFromGlobal()
End If
Next