0

I want to determine if something has changed in a catpart that would drive a change in a body, but the change hasnt been done because update is set to manual.

I have tried:

if part.product.update = true then
    'do something
else
  'do something else
endif

However this just forces an update and doesnt tell me if one was required.

RyanL
  • 1,246
  • 2
  • 10
  • 14
tink
  • 11
  • 5

2 Answers2

1

I worked out a solution (see below) '@@@@@@@@@@@@@@@@@@@@@

Function func_CheckNoModsSinceLastSaved() As Boolean

func_CheckNoModsSinceLastSaved = False

Dim flg_NoModsSinceLastSaved As Boolean

flg_NoModsSinceLastSaved = False

If Right(CATIA.ActiveDocument.FullName, 11) = ".CATProduct" Then
    Dim productDocument1 As ProductDocument
    Set productDocument1 = CATIA.ActiveDocument

    Dim product1 As Product
    Set product1 = productDocument1.Product

    flg_NoModsSinceLastSaved = productDocument1.Saved
    If flg_NoModsSinceLastSaved Then
        func_CheckNoModsSinceLastSaved = True
    Else
        func_CheckNoModsSinceLastSaved = False
        MsgBox "Modified Since Last Saved"
    End If

    product1.Update

    flg_NoModsSinceLastSaved = productDocument1.Saved
    If flg_NoModsSinceLastSaved Then
        func_CheckNoModsSinceLastSaved = True
    Else
        func_CheckNoModsSinceLastSaved = False
        MsgBox "Modified Since Last Saved"
    End If

    Set productDocument1 = Nothing


ElseIf Right(CATIA.ActiveDocument.FullName, 8) = ".CATPart" Then
    Dim partDocument1 As PartDocument
    Set partDocument1 = CATIA.ActiveDocument


    flg_NoModsSinceLastSaved = partDocument1.Saved
    If flg_NoModsSinceLastSaved Then
        func_CheckNoModsSinceLastSaved = True
    Else
        func_CheckNoModsSinceLastSaved = False
        MsgBox "Modified Since Last Saved"
    End If

    partDocument1.Part.Update

    flg_NoModsSinceLastSaved = partDocument1.Saved
    If flg_NoModsSinceLastSaved Then
        func_CheckNoModsSinceLastSaved = True
    Else
        func_CheckNoModsSinceLastSaved = False
        MsgBox "Modified Since Last Saved"
    End If
    Set partDocument1 = Nothing


ElseIf Right(CATIA.ActiveDocument.FullName, 11) = ".CATDrawing" Then
    Dim drawingDocument1 As DrawingDocument
    Set drawingDocument1 = CATIA.ActiveDocument

    flg_NoModsSinceLastSaved = drawingDocument1.Saved
     If flg_NoModsSinceLastSaved Then
        func_CheckNoModsSinceLastSaved = True
    Else
        func_CheckNoModsSinceLastSaved = False
        MsgBox "Modified Since Last Saved"
    End If

    drawingDocument1.Update

    flg_NoModsSinceLastSaved = drawingDocument1.Saved
    If flg_NoModsSinceLastSaved Then
        func_CheckNoModsSinceLastSaved = True
    Else
        func_CheckNoModsSinceLastSaved = False
        MsgBox "Modified Since Last Saved"
    End If
    Set drawingDocument1 = Nothing

Else
    MsgBox "ERROR: Unidentified File Type!", vbCritical + vbOKOnly, ""
End If
End Function

'@@@@@@@@@@@@@@@@@@@@@

tink
  • 11
  • 5
0

Check CATIA Settings

Set mySettControlers = CATIA.SettingControllers
Set myPartInfraSetting = mySettControlers.Item("CATMmuPartInfrastructureSettingCtrl")

Check how is set myPartInfraSetting.UpdateMode and see if is catManualUpdate or catAutomaticUpdate

ferdo
  • 178
  • 4
  • (assuming you are the same ferdo from catiav5forum.de, hello hope you are doing well).. im not sure if that will tell me anything. thats is just what the update mode is set to. i am more concerned with if someone has there update mode set to manual makes a change on a sketch but does not update the body. how to detect if the body isnt uptodate. – tink Feb 16 '17 at 21:50
  • Hello, yes, same guy here, :-) , thanks, you are right, now I understood what is your concern. Anyway, first you have to check how your settings are set so your CATIA will not update automatically something without let you know (even if you will get an alert when closing). So, indeed, problem not solved but frankly speaking I didn't see anything in documentation. Are your users using Q-Checker or something similar? – ferdo Feb 18 '17 at 20:20
  • no, and frankly i get so much rubbish, unupdated bodies, broken links, ghost links, not adhering to naming and numbering standards (i see files called Part1.CATPart quite a lot from my colleagues and customers) am just trying to make some tools to rapidly scan for problems. – tink Feb 18 '17 at 21:58
  • basically am writing a cad management system -its actually going quite well, this is just another test in a long line of things to prevent my users putting dodgy data into it - been trying to get my bosses to buy one for years, given up and am writing my own. – tink Feb 18 '17 at 22:05
  • In my opinion, you can do a macro to be run by each of the users/customers to fulfill your design rules before saving and warn users what is wrong. The only problem is to implement this, but each company should have some formal design rules.... – ferdo Feb 20 '17 at 06:03
  • 'should have' being the operative statement. – tink Feb 20 '17 at 09:29
  • and unless its automatically part of the storing the data process they probably wont use it (they will say they dont have time) do you know of a 'save' event in catia i could use to automatically run the macro (or would i need caa rade)? – tink Feb 20 '17 at 09:34