evereux / pycatia

python module for CATIA V5 automation
MIT License
204 stars 53 forks source link

[QUESTION] REMOVE THE PARAMETERSET ??? #215

Closed ozserhatt closed 5 months ago

ozserhatt commented 6 months ago
from pycatia import catia
from pycatia.mec_mod_interfaces.part import Part
from pycatia.mec_mod_interfaces.part_document import PartDocument
from pycatia.knowledge_interfaces.parameters import Parameters

caa = catia()
application = caa.application
document = PartDocument(caa.active_document.com_object)
part = Part(document.part.com_object)
bodies = part.bodies

part_parameters = part.parameters

root_parameter_set = part_parameters.root_parameter_set

parameter_sets = root_parameter_set.parameter_sets

sub_parameter_set = Parameters(parameter_sets.parameter_sets)

for parm_set in sub_parameter_set:
    print(parm_set.name)

HOW CAN I REMOVE THE PARAMETERSET ???

ozserhatt commented 6 months ago

image

evereux commented 6 months ago

I've edited your post to format your code again. Please, edit your reply to see how I did that.

The Parameters object has a method called remove. You should be able to pass it the parameter name or index to remove it.

ozserhatt commented 5 months ago

I can remove parameters but I can not remove a parameterset. So I will try again for you..

evereux commented 5 months ago

My apologies for that. I misread the question, totally my fault. I'll take a look at this again.

evereux commented 5 months ago

This deletes the ParameterSet called delete_me.

I worked this out by recording a macro and reading the generated code to give me clues. I can't stress enough how valuable a tool this is.

Couldn't see any other way to do it as the ParameterSets collection object has no method for deleting.


from pycatia import catia
from pycatia.mec_mod_interfaces.part import Part
from pycatia.mec_mod_interfaces.part_document import PartDocument
from pycatia.knowledge_interfaces.parameters import Parameters

caa = catia()
application = caa.application
part_document = PartDocument(caa.active_document.com_object)
selection = part_document.selection

part = part_document.part
bodies = part.bodies

part_parameters = part.parameters

root_parameter_set = part_parameters.root_parameter_set

parameter_sets = root_parameter_set.parameter_sets

delete_me = parameter_sets.item("delete_me")

selection.clear()
selection.add(delete_me)
selection.delete()
ozserhatt commented 5 months ago

Good stuff. That is a cleverly. :) Well done!