Autor
|
Thema: remove constraints in product and subproduct with catvbs (2165 mal gelesen)
|
stefanandreas Mitglied Student
Beiträge: 22 Registriert: 24.04.2003
|
erstellt am: 15. Mai. 2006 17:22 <-- editieren / zitieren --> Unities abgeben:
Hello, I need to remove all constraints in a product and in his subproducts. Therefore I set up a loop, where I use the Connections method to get and remove all constraints. in the rootproduct it works, but in the subproduct not. When I try to debug in the VB Editor, the product.connection seems to be alright (right number of constraints). Remove function gives no error, but doesnt work. the item method of the product.connection gives the error: Runtime error '-2147352565(8002000b)' - "the method item failed". when I open a subproduct alone, so it is the rootproduct in CATIA.ActiveDocument, it works without problem. where is my failure Set prodconst = iProduct.Connections("CATIAConstraints") For k = 1 To prodconst.Count 'MsgBox prodconst.Item(1).Name prodconst.Remove (1) Next Set prodconst = iProduct.Connections("CATIAFixTogethers") For k = 1 To prodconst.Count prodconst.Remove (1) Next thanks for any help best regards Stefan Rulhoff Ps : CATIA V5 P2 R14 SP3 on WinXPSP2.. Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
Lusilnie Mitglied
Beiträge: 1486 Registriert: 13.07.2005
|
erstellt am: 16. Mai. 2006 00:01 <-- editieren / zitieren --> Unities abgeben: Nur für stefanandreas
Hallo stefanandreas, why do you use not the search-function to resolve your problem? You can record the macro by the macro-recorder and change the script for your demand. Here an example code:
Code: Sub CATMain()Dim productDocument1 As productDocument Set productDocument1 = CATIA.ActiveDocument Dim selection1 As selection Set selection1 = productDocument1.selection selection1.Search "CATAsmSearch.MfConstraint,all" selection1.Delete End Sub
This is the code for all constraints. If you want to select special types of constraints, you must change the "search"-line to this, for example for fix-constraints: selection1.Search "CATAsmSearch.MfFixConstraint,all" kind regards, Lusilnie
------------------
Alle Aussagen zu DassaultSystemes-Produkten sind sehr optimistisch, selbst diese!!! frei nach größeren Geistern Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
stefanandreas Mitglied Student
Beiträge: 22 Registriert: 24.04.2003
|
erstellt am: 17. Mai. 2006 09:52 <-- editieren / zitieren --> Unities abgeben:
Hi Lusilnie, vielen Dank für Deine Antwort. Die Suche hatte ich auch schon in Betracht gezogen, hatte aber das Problem: Die Suche nach 'Assembly Design'.Constraint;All findet alle Constraints, auch die in Skizzen. Woher hast du Deine Suchabfrage CATAsmSearch.MfConstraint,all ? Ich konnte das in der Doku nicht finden. Leider habe ich bei Deinem Script folgendes Problem: Wenn ich das Script einmal über das Product laufen lasse, löscht es schön alle Baugruppenconstraints. Wenn ich es dann ein zweitesmal drüberlaufen lasse, löscht es leider auch alle Sketch Contraints aus allen Sketchen. Wie kann man das verhindern, bzw. nur die Baugruppenconstraints sicher und automatisiert löschen? Liebe Grüße Stefan Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
tomtom1972 Mitglied dipl ing maschinenbau
Beiträge: 605 Registriert: 22.03.2005 NVidia Quadro K4000 Intel Xeon E5-1620, 64GB RAM Windows10 64bit R30 <= CATIA V5 > =R19
|
erstellt am: 17. Mai. 2006 12:51 <-- editieren / zitieren --> Unities abgeben: Nur für stefanandreas
Hallo, das Script im Anhang löscht bzw. fixiertt alles (Baugruppen Constraints) innerhalb der geöffneten Struktur. Probiers mal aus, müsste das sein, was du suchst. Anhang von .txt in .CATScript ändern. Gruss TomTom ------------------ tomtom1972 Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
stefanandreas Mitglied Student
Beiträge: 22 Registriert: 24.04.2003
|
erstellt am: 17. Mai. 2006 14:56 <-- editieren / zitieren --> Unities abgeben:
Hi TomTom, vielen Dank für dein Script. Dadurch habe ich meinen Fehler gefunden, welcher natürlich nicht in den paar Beispielzeilen war, die ich zuerst gepostet hatte. Ich habe ähnlich wie in deinem Script eine Sub, welche Rekursiv durch die Productstruktur geht. Mein Fehler war, beim Aufruf der Sub aus der Sub selbst, wurde anstatt dem eigentlichen Unterprodukt die Instanz davon übergeben. Mit der Instanz konnte ich dann natürlich nicht direkt über iProduct.Connections("CATIAConstraints") auf die Constraints zugreifen. Deshalb hatte ich den Effekt, das im rootprodukt alle Constraints entfernt wurden und in den Subprodukten nicht mehr. Also vielen Dank nochmal, Liebe Grüße Stefan Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
| Anzeige.:
Anzeige: (Infos zum Werbeplatz >>)
|