Hot News:

Mit Unterstützung durch:

  Foren auf CAD.de
  CATIA V5 Programmierung
  Catia copied parts to axis in product

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
  
CATIA V5 Grundkurs | Einsteiger - 5 Std. 15 Min 48
  
KISTERS 3DViewStation: Multitalent für Branchen und Nischenmärkte, eine Pressemitteilung
Autor Thema:  Catia copied parts to axis in product (699 mal gelesen)
Mert123
Mitglied
Mechanical Engineer

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

Beiträge: 6
Registriert: 12.08.2023

erstellt am: 17. Aug. 2023 15:33    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


image.png


image1.png


image2.png

 
Hey, I working on die design and I have lots of same part and I bored for putting them to axises one by one sometimes 50 or 100 parts.

So I think and found a solution but I'm stuck in code section. What can I do?

for coincidence I got this code how can I edit this selected parts or cycle for all copied parts:

Code:
Sub CATMain()

Dim productDocument1 As productDocument
Set productDocument1 = CATIA.ActiveDocument

Dim product1 As product
Set product1 = productDocument1.product

Dim constraints1 As constraints
Set constraints1 = product1.Connections("CATIAConstraints")

Dim reference1 As Reference
Set reference1 = product1.CreateReferenceFromName("work/Part2.5/!Absolute Axis System")

Dim reference2 As Reference
Set reference2 = product1.CreateReferenceFromName("work/Part1.2/!Axis System.6")

Dim constraint1 As constraint
Set constraint1 = constraints1.AddBiEltCst(catCstTypeOn, reference1, reference2)

product1.Update

End Sub



For copying I made this one and I changed it but I got some errors...

Probably its reads product or just part?

Code:
Sub CATMain()
    Dim copyCountStr As String
    copyCountStr = InputBox("enter the copied parts:", "copy number", "1")
 
    If IsNumeric(copyCountStr) Then
        Dim copyCount As Integer
        copyCount = CInt(copyCountStr)
     
        If copyCount > 0 Then
            Dim productDocument1 As productDocument
            Set productDocument1 = CATIA.ActiveDocument

            Dim selection1 As selection
            Set selection1 = productDocument1.selection

            selection1.Clear

            Dim product1 As product
            Set product1 = productDocument1.product

            Dim products1 As products
            Set products1 = product1.products

            Dim product2 As product
            Set product2 = products1.item("Part2.1")

            selection1.Add product2

            selection1.Copy

            Dim i As Integer
            For i = 1 To copyCount
                selection1.Clear
                selection1.Add product1
                selection1.Paste
            Next i
        Else
            MsgBox "enter a valid possitive number"
        End If
    Else
        MsgBox "enter a valid number"
    End If
End Sub



------------------
yunus

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

bgrittmann
Moderator
Konstrukteur


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

Beiträge: 12054
Registriert: 30.11.2006

CATIA V5R19

erstellt am: 17. Aug. 2023 16:50    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 Nur für Mert123 10 Unities + Antwort hilfreich

Hi,

Here an example how I would solve this:

Code:
Sub CATMain()

Dim oSel as Selection
Dim oRootProduct as Product
Dim sFilter(0) as String
Dim sStatus
Dim oSourceProduct as Product
Dim i as Integer
Dim oConstaints as constraints
Dim oNewInstance As Product
dim sRef1 as String
dim sRef2 as String
dim oRef1 as Reference
dim oRef2 as Reference

Dim oTargetAxisSystem as Axissystem
Dim oSourceAxisSystem as Axissystem

Set oRootProduct = Catia.ActiveDocument.Product
Set oSel = Catia.ActiveDocument.Selection
Set oConstaints = oRootProduct.Connections("CATIAConstraints")

'select part which shall be patterned
sFilter(0)="AxisSystem"

sStatus = oSel.SelectElement2(sFilter,"Please select axis-system in patterned part", false)

if (Status = "Cancel") then Exit Sub

Set oSourceAxisSystem = oSel.Item2(1).Value
Set oSourceProduct = oSel.Item2(1).LeafProduct

'select axis-systems to connect
oSel.Clear
sStatus = oSel.SelectElement3(sFilter,"Please select source axisystems", false,CATMultiSelTriggWhenUserValidatesSelection ,false)
if (Status = "Cancel") then Exit Sub

for i = 1 to oSel.count2

  Set oNewInstance = oRootProduct.Products.AddComponent(oSourceProduct.ReferenceProduct)

  sRef1 = oRootProduct.Name & "/" & oNewInstance.Name & "/!" & oSourceAxisSystem.Name
  Set oRef1 = oRootProduct.CreateReferenceFromName(sRef1)

  sRef2 = oRootProduct.Name & "/" & oSel.Item2(i).LeafProduct.Name & "/!" & oSel.Item2(i).Value.Name
  Set oRef2 = oRootProduct.CreateReferenceFromName(sRef2) 
  Set oConstrain = oConstaints.AddBiEltCst(catCstTypeOn, oRef1, oRef2)
 
next

oRootProduct.Update

End Sub


Code is not tested. Also error handling is missing.
Have fun analyzing the code

regards,
Bernd

------------------
Warum einfach, wenn es auch kompliziert geht.

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

Mert123
Mitglied
Mechanical Engineer

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

Beiträge: 6
Registriert: 12.08.2023

erstellt am: 17. Aug. 2023 17:24    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

Zitat:
Original erstellt von bgrittmann:
Hi,

Here an example how I would solve this:

Code:
Sub CATMain()

Dim oSel as Selection
Dim oRootProduct as Product
Dim sFilter(0) as String
Dim sStatus
Dim oSourceProduct as Product
Dim i as Integer
Dim oConstaints as constraints
Dim oNewInstance As Product
dim sRef1 as String
dim sRef2 as String
dim oRef1 as Reference
dim oRef2 as Reference

Dim oTargetAxisSystem as Axissystem
Dim oSourceAxisSystem as Axissystem

Set oRootProduct = Catia.ActiveDocument.Product
Set oSel = Catia.ActiveDocument.Selection
Set oConstaints = oRootProduct.Connections("CATIAConstraints")

'select part which shall be patterned
sFilter(0)="AxisSystem"

sStatus = oSel.SelectElement2(sFilter,"Please select axis-system in patterned part", false)

if (Status = "Cancel") then Exit Sub

Set oSourceAxisSystem = oSel.Item2(1).Value
Set oSourceProduct = oSel.Item2(1).LeafProduct

'select axis-systems to connect
oSel.Clear
sStatus = oSel.SelectElement3(sFilter,"Please select source axisystems", false,CATMultiSelTriggWhenUserValidatesSelection ,false)
if (Status = "Cancel") then Exit Sub

for i = 1 to oSel.count2

   Set oNewInstance = oRootProduct.Products.AddComponent(oSourceProduct.ReferenceProduct)

   sRef1 = oRootProduct.Name & "/" & oNewInstance.Name & "/!" & oSourceAxisSystem.Name
   Set oRef1 = oRootProduct.CreateReferenceFromName(sRef1)

   sRef2 = oRootProduct.Name & "/" & oSel.Item2(i).LeafProduct.Name & "/!" & oSel.Item2(i).Value.Name
   Set oRef2 = oRootProduct.CreateReferenceFromName(sRef2) 
   Set oConstrain = oConstaints.AddBiEltCst(catCstTypeOn, oRef1, oRef2)
  
next

oRootProduct.Update

End Sub


Code is not tested. Also error handling is missing.
Have fun analyzing the code

regards,
Bernd



I got error like this my bad:

Compile error: function or interface marked as restricted, or the function uses an Automation type not supported in Visual Basic

If in your free time can you send me example with an assembly? Thank you for everything.

Best regards Mert.

------------------
I don't know what I am doing

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

bgrittmann
Moderator
Konstrukteur


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

Beiträge: 12054
Registriert: 30.11.2006

CATIA V5R19

erstellt am: 17. Aug. 2023 17:27    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 Nur für Mert123 10 Unities + Antwort hilfreich

Hi,

Please have a look on here

Bernd

------------------
Warum einfach, wenn es auch kompliziert geht.

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

Mert123
Mitglied
Mechanical Engineer

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

Beiträge: 6
Registriert: 12.08.2023

erstellt am: 17. Aug. 2023 17:36    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

Zitat:
Original erstellt von bgrittmann:
Hi,

Please have a look on here

Bernd


It's worked I tried in catsciprt I need to learn lots of things how can I improve myself in macro can you advice anything? In here I didn't find tutorial or guide for macro or etc because its german  A newbie mistake by me thank you again. Btw is it possible copy of this parts and copies goes other axises?

------------------
I don't know what I am doing

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

bgrittmann
Moderator
Konstrukteur


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

Beiträge: 12054
Registriert: 30.11.2006

CATIA V5R19

erstellt am: 17. Aug. 2023 17:45    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 Nur für Mert123 10 Unities + Antwort hilfreich

Hi,

probably there are also English books for macro programming. Also forums in English are available.
I suggest to learn the use of the documentation and the use of the vba editor (watch/local windows)

regards,
Bernd

------------------
Warum einfach, wenn es auch kompliziert geht.

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)2025 CAD.de | Impressum | Datenschutz