Mean to know if a node shape is activated or not
Mean to know if a node shape is activated or not
(OP)
Hi,
I'm looking for how to know if a shape is activated or not.
Because I would like to retrieve the visualization status of a product with the option "Do not activate default Shapes on open" activated.
In fact, I lose every evening my session which is a big session in which I don't want to activate all shapes because it's too heavy. This is a society rule and i can't prevent it.
But It takes lot of time to activate shapes by shapes or set of shapes activating terminal nodes so as it would be ineresting to make a quick configuration status every evening before the CATIA crash. Thus, the following day i could load my session with the same shapes open with a macro.
I didn't find anything concerning this property. I only saw that we can activate/deactivate nodes or terminal nodes with "start.command"
if anyone can help, find a trick, i would really appreciate.
I'm looking for how to know if a shape is activated or not.
Because I would like to retrieve the visualization status of a product with the option "Do not activate default Shapes on open" activated.
In fact, I lose every evening my session which is a big session in which I don't want to activate all shapes because it's too heavy. This is a society rule and i can't prevent it.
But It takes lot of time to activate shapes by shapes or set of shapes activating terminal nodes so as it would be ineresting to make a quick configuration status every evening before the CATIA crash. Thus, the following day i could load my session with the same shapes open with a macro.
I didn't find anything concerning this property. I only saw that we can activate/deactivate nodes or terminal nodes with "start.command"
if anyone can help, find a trick, i would really appreciate.





RE: Mean to know if a node shape is activated or not
Then, I would create a macro to read this file (or a modified one) to select back what was it in CATIA tree, then run activate command.
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Mean to know if a node shape is activated or not
it seems a good Idea. I will investigate in this direction.
tks a lot.
RE: Mean to know if a node shape is activated or not
I didn't find the macro that you're talking about so I have made one by myself that you can see below :
CODE --> VBA
Sub ExportProductName() Set CATIA = GetObject(, "CATIA.Application") Set activdoc = CATIA.ActiveDocument.Product Set oSel = CATIA.ActiveDocument.Selection nbelts = oSel.Count2 Dim NumFic As Integer Dim chemin As String chemin = "D:\TEMP\Sauvegarde_VisProduct.txt" Dim oFile, oTextStream sFilePath = chemin Set oFile = CATIA.FileSystem.CreateFile(sFilePath, True) Set oTextStream = oFile.OpenAsTextStream("ForWriting") For i = 1 To nbelts oTextStream.Write oSel.Item2(i).LeafProduct.Name Next iEnd Sub Sub selectelt() Set CATIA = GetObject(, "CATIA.Application") Set activdoc = CATIA.ActiveDocument.Product Set oSel = CATIA.ActiveDocument.Selection Dim n As Integer Dim i As Long 'Integer Depassement de capacité à 37323 n = FreeFile Dim chemin As String chemin = "D:\TEMP\Sauvegarde_VisProduct.txt" Open chemin For Input As #n Do While Not EOF(1) Line Input #n, prod oSel.Search ("'Product Structure'.Product.Name='" & prod & "',all") CATIA.StartCommand ("Activate Terminal Node") oSel.Clear Loop Close #n End Subit works but it takes such a long time that it is better to do the work manually... I don't understand why it is so long !
could you please send me the code to export the tree selection ?
RE: Mean to know if a node shape is activated or not
The macro bellow is from v5automation.chm file...by the way, what release do you use?
CODE --> CATScript
Option Explicit ' *********************************************************************** Sub BuildName ( ByRef ioProduct, ByRef osName ) osName = ioProduct.Name Dim oRoot As Product Set oRoot = CATIA.ActiveDocument.Product Dim oCurrent As Product Set oCurrent = ioProduct While (oCurrent.Name <> oRoot.Name) Set oCurrent = oCurrent.Parent.Parent osName = oCurrent.Name+"\"+osName Wend End Sub ' *********************************************************************** ' ' Purpose: Main. ' ' *********************************************************************** Sub CATMain() ' Initialize Dim sTitle As String sTitle = "Write name of selected products" Dim sExtension As String sExtension = "txt" ' Create the file environment Dim oFso As FileSystem Set oFso = CATIA.FileSystem Dim oFile As File Dim oTextStream As CATIATextStream ' Open the output file Dim iReturnCode As Integer iReturnCode = vbRetry While (iReturnCode = vbRetry) ' Retrieve the path from the user Dim sFilePath As String sFilePath = CATIA.FileSelectionBox(sTitle, sExtension,CatFileSelectionModeSave) If (sFilePath = "") Then iReturnCode = vbCancel Else ' Verify the existence of the output file sFilePath = sFilePath+"."+sExtension Dim iOverwrite As Boolean iOverwrite = False If (oFso.FileExists(sFilePath)) Then ' Ask user if output file exists iReturnCode = Msgbox("The file already exists! Do you want to overwrite it ?", vbQuestion+vbAbortRetryIgnore, sTitle) If (iReturnCode = vbAbort) Then iReturnCode = vbCancel ElseIf (iReturnCode = vbIgnore) Then iReturnCode = vbOK iOverwrite = True End If else iReturnCode = vbOK End If ' Create the output file If (iReturnCode = vbOK) Then On Error Resume Next Set oFile = oFso.CreateFile(sFilePath, iOverwrite) If (Err.Number <> 0) Then Err.Clear iReturnCode = Msgbox("Cannot Create !",vbExclamation+vbRetryCancel, sTitle) Else ' Open the output file Set oTextStream = oFile.OpenAsTextStream("ForWriting") If (Err.Number <> 0) Then iReturnCode = Msgbox("Cannot open as a text file for writting !", vbExclamation+vbRetryCancel, sTitle) End If End If On Error goto 0 End If End If Wend ' Write the name of selected products If (iReturnCode = vbOK) Then Dim oSelection As Selection Set oSelection = CATIA.ActiveDocument.Selection ' Retrieve the selected products Dim oProduct As AnyObject Dim sCompleteName As String On Error Resume Next While (Err.Number = 0) Set oProduct = oSelection.FindObject("CATIAProduct") If (Err.Number = 0) Then ' Write the name BuildName oProduct, sCompleteName oTextStream.Write sCompleteName+vbCrLf End If Wend On Error Goto 0 ' Clean Set oFile = Nothing Set oFso = Nothing ' Report Msgbox sTitle+" completed !" End If End SubRegards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Mean to know if a node shape is activated or not
this macro is also too long for thousands of parts...
RE: Mean to know if a node shape is activated or not
- disable internal selection object update
Dim HSOSynchronizedFilter(0)
HSOSynchronizedFilter(0) = "SetCATIADotHSOSynchronizedToFalse"
and at the end
- re-enable internal selection object update
HSOSynchronizedFilter(0) = "SetCATIADotHSOSynchronizedToTrue"
Check the documentation about this.
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Mean to know if a node shape is activated or not
Nevertheless I've tried with it but without success. It takes 35s for 600 parts and I have more than ten thousand parts.
I think now that it would be better to select directly in specification tree the main nodes and to trigger "activate terminal nodes". It's not sexy but it works well if you keep CTRL pushed down.