Search code examples
catia

KWA Catia R24 - Activate / Deactivate components by script (Problem with Extrude)


I have created simple code to Activate/Deactivate components in GS (with simple modification you can also Hide/Show components) in 99% cases it works but I have noticed that there is a problem with EXTRUDE this script is able to deactivate all EXTRUDE Functions but there is a problem when I would like to Activate them. I have noticed that script can't find and add to the list deactivated EXTRUDE functions and I have no idea why. Thank you in advance for your help

Below you can find my code:

Main code in ACTION:

GeometricalSet :  OpenBodyFeature,visState :  Boolean 

let AxisSystems_List (List)
let Wireframe_List (List)
let Sketch_List (List)
let Wireframe_List (List)
let Surfaces_List (List)

let AxisSystem_GEO (AxisSystem)
let Wireframe_GEO (Wireframe)
let Sketch_GEO (Sketch)
let Surfaces_GEO (Surface)

AxisSystems_List  = GeometricalSet ->Query("AxisSystem","")
Wireframe_List = GeometricalSet ->Query("Wireframe","")
Sketch_List = GeometricalSet ->Query("Sketch","")
Surfaces_List = GeometricalSet ->Query("Surface","")

for AxisSystem_GEO inside AxisSystems_List 
{
    AxisSystem_GEO.Activity = visState

}

for Wireframe_GEO inside Wireframe_List 
{
    Wireframe_GEO.Activity = visState

}

for Sketch_GEO inside Sketch_List 
{
    Sketch_GEO.Activity = visState

}

for Surfaces_GEO inside Surfaces_List
{
    Surfaces_GEO.Activity = visState

}

Reaction to Run script:

if String.1 =="YES"
{

    `Relations\Rules\Action deactivate`  ->Run(`Geometrical Set.109`,true)

}

else if String.1=="NO"
{

    `Relations\Rules\Action deactivate`  ->Run(`Geometrical Set.109`,false)
}


Solution

  • The Extrude is not necessarily a surface. You can extrude a point into a line for example.

    I think what is happening, is when the feature is deactivated, there is no surface, so nothing is returned during the query. CATIA seems to only care about the resulting shape and not so much about the object type - when you query for "Surface".

    If you query for and process "GSMExtrude" instead of "Surface" you will find that it works.

    So maybe you could do, when gathering the object to re-activate:

    lObjects = geoset->Query("Surface","") + geoset->Query("GSMExtrude","")
    

    Which should get you everything. It makes things complicated when re-activating for sure.

    The same thing may also apply to other types, perhaps the Split feature. The Split can also be a surface or it can be a curve.