Hot News:

Mit Unterstützung durch:

  Foren auf CAD.de (alle Foren)
  CATIA V5 Programmierung
  Copy/Paste with link einen Body der in einem instancierter Product ist.

Antwort erstellen  Neues Thema erstellen
CAD.de Login | Logout | Profil | Profil bearbeiten | Registrieren | Voreinstellungen | Hilfe | Suchen

Anzeige:

Darstellung des Themas zum Ausdrucken. Bitte dann die Druckfunktion des Browsers verwenden. | Suche nach Beiträgen nächster neuer Beitrag | nächster älterer Beitrag
Autor Thema:  Copy/Paste with link einen Body der in einem instancierter Product ist. (1588 mal gelesen)
tr
Mitglied
Dipl.-Ing., Maschinenbau


Sehen Sie sich das Profil von tr an!   Senden Sie eine Private Message an tr  Schreiben Sie einen Gästebucheintrag für tr

Beiträge: 32
Registriert: 12.05.2003

erstellt am: 28. Mai. 2003 10:56    Editieren oder löschen Sie diesen Beitrag!  <-- editieren / zitieren -->   Antwort mit Zitat in Fett Antwort mit kursivem Zitat    Unities abgeben: 1 Unity (wenig hilfreich, aber dennoch)2 Unities3 Unities4 Unities5 Unities6 Unities7 Unities8 Unities9 Unities10 Unities

Hi,

I try to copy a Body of an instanciate Part into an other Part but if I work with objects, Catia returns always the body of the first instance.

That’s my first script but it doesn’t work (In a first time I tried to copy the complete instanciate Part before trying to copy a Body...)

Sub test()

Set root = CATIA.ActiveDocument.Product.Products
Set subprod = root.Item("Sub-Product_in_root").Products
Set subprod2 = subprod.Item("Product_in_Sub-Product").Products
Set subprod3 = subprod2.Item("Product_containing_the_instanciated_products").Products
Set lastinstance = subprod3.Item("Instance.4").Products
Set Partprod = lastinstance.Item("Part.1").ReferenceProduct.Parent
Set copybody = Partprod.part

Dim oSelElem As SelectedElement
CATIA.ActiveDocument.Selection.Add (copybody)

End Sub

Ok, now I know that it’s not possible to use the objects. So I tried to use the search function.

First sample:

Search the Body in the complete document. 2 possibilities:
1- The Body is at the end of the selection, ok, I use the findObject function to remove the prevorious elements.
2- The Body is not at the end: Problem because I can’t remove a specified item from the selection. In fact I can find out the item position in the selection if the selected item x is contained in my instanciate part:

Sub test49()
Dim productDocument1 As Document
Set productDocument1 = CATIA.ActiveDocument

Dim selection1 As Selection
Set selection1 = productDocument1.Selection

selection1.Clear
selection1.Search "Name='Searched_Body',all"

ReDim test_array(selection1.Count - 1)
'ReDim test_array_2(selection1.Count - 1)

For i = 0 To selection1.Count - 1
'Set test_array_2(i) = selection1.Item(1)
'Findobject remove the foundobject from selection
Set FoundObject = selection1.FindObject("CATIAProduct")
If FoundObject.Parent.Parent.Name = "instance_name" Then
test_array(i) = 1
Else
test_array(i) = 0
End If
Next

selection1.Clear
selection1.Search "Name='Searched_Body',all"

'Remove from selection à seems no to be possible
For i = 0 To selection1.Count - 1
'Set sel = selection1.Item(i + 1)
If test_array(i) = 0 Then

'Doesn’t work:
'Set ert = selection1.Item(i + 1).FindObject("CATIAProduct")
'Selection.Item(i + 1) = Nothing
'Selection.Item(i + 1) = ""

Else
'Item (i+1) contained in the specified instance, OK
End If
Next

End Sub


That method doesn’t work because I can’t remove a specified Item from the selection.

2 bis- Search use the „search in“ function:

Sub test50()
Dim productDocument1 As Document
Set productDocument1 = CATIA.ActiveDocument
Dim selection1 As Selection
Set selection1 = productDocument1.Selection
selection1.Clear
selection1.Search "Name='Searched_Body',in"
selection1.Copy
End Sub

But in that case, I have to activate the instancited Part with a double-clik. This method work but I need to find out how to activate this last instanciated Part...

Can you help me ? because I have no other idea for the moment.
Thanks

Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP

Anzeige.:

Anzeige: (Infos zum Werbeplatz >>)

Darstellung des Themas zum Ausdrucken. Bitte dann die Druckfunktion des Browsers verwenden. | Suche nach Beiträgen

nächster neuerer Beitrag | nächster älterer Beitrag
Antwort erstellen


Diesen Beitrag mit Lesezeichen versehen ... | Nach anderen Beiträgen suchen | CAD.de-Newsletter

Administrative Optionen: Beitrag schliessen | Archivieren/Bewegen | Beitrag melden!

Fragen und Anregungen: Kritik-Forum | Neues aus der Community: Community-Forum

(c)2023 CAD.de | Impressum | Datenschutz