Foros CATIA

1 envío / 0 nuevos
Inicie sesión o regístrese para comentar
chago20
Desconectado/a
Visto por última vez: Hace 12 años 4 meses
se unió: 09/12/2011 - 17:37
Macro para copiar varios Pads

Buen día,

Me gustaría ver si alguien me puede ayudar en lo siguiente:

Voy a crear una macro que me permita seleccionar "X" cantidad de pads dentro de un CatPart para luego copiarlas y pegarlas dentro de un Body que yo también seleccionaré...

No se cuales instrucciones utilizar para la selección de diferentes items...

Además, si alguien tiene una lista de las instrucciones y para qué sirven le agradecería mucho que me las pasara...

 

Saludos,


Desconectado/a

Visto por última vez: Hace 4 años 1 mes

se unió: 09/01/2008 - 13:48

Posts:

Hola chago

Te dejo la ayuda del comando seleciton:

Represents the selection.
The Selection object contains the features the end user selected, usually with the mouse, and which are candidates as subjects for the next action.

A feature possess parent objects in the specification tree (hierarchy). For example, the Pad below possess parent objects in the specification tree:

   +--------+ 

!Product3!
+--------+
!
+- Product2 (Product2.1)
! !
! +- Product1 (Product1.1)
! !
! +- Part1 (Part1.1)
! !
! +- Part1
! !
! +- PartBody
! ! +------------------+
! +- Pad.1 ! Selected feature !
! ! +------------------+
! +- Sketch.1
+- Part2 (Part2.1)

For a given selected feature, its parent objects which are exposed to automation can be accessed through a recursive call to the AnyObject.Parentproperty. When a given feature is selected, there are three possibilities:

  • The feature is exposed to automation (a Pad for example, this is the common case): the feature can be accessed by all Selection object methods
  • The feature is not exposed to automation, but at least one of its parent objects is exposed to automation (a DMU Navigator URL for example: the Hyperlink is not exposed to automation, but the root Product, which contains the Hyperlink, is exposed to automation):
    • no access is given to the feature through the Count2 and Item2 methods of the Selection object
    • nevertheless, the first parent object of the feature, which is exposed to automation (the root Product in our example) can be accessed through the Item2 and Count2 methods
    • The Search, Delete, VisProperties, Copy, Cut, Paste and PasteSpecial methods of the Selection object, take into account the feature.
      For example, if the user:
      • Puts a DMU Navigator URL in the clipboard
      • Runs a script calling the PasteSpecial method
      then, during the paste, the DMU Navigator URL will be pasted
  • The feature is not exposed to automation, and he has no parent object which is exposed to automation (a ResourcesList object of a .CATProcess for example):
    • no access is given to the feature through the Count2 and Item2 methods of the Selection object
    • no access is given neither to any parent object of the feature through the Item2 and Count2 methods
    • The Search, Delete, VisProperties, Copy, Cut, Paste and PasteSpecial methods of the Selection object take into account the feature.
      For example, if the user:
      • Go to the "DPM - Process and Resource Definition" workshop
      • Puts a ResourcesList object in the clipboard
      • Runs a script calling the Selection.PasteSpecial method
      then, during the paste, the ResourcesList object will be pasted.

Note: The Selection object can be accessed through the Document.Selection property . However, when the active window contains the tree described above, the Selection object to use is the one associated to the Product3 Document , which can be accessed through the application of the Document.Selection to this document. You will, for example, determine the Selectionobject the following way:

 Set ActiveProductDocument = CATIA.ActiveDocument 

Set Product3 = ActiveProductDocument.Product
Set Product3Products = Product3.Products
Set Product2Dot1 = Product3Products.Item("Product2.1") : Set Product2 = Product2Dot1.ReferenceProduct
Set ProductDocument2 = Product2.Parent
Set Product2Products = Product2.Products
Set Product1Dot1 = Product2Products.Item("Product1.1") : Set Product1 = Product1Dot1.ReferenceProduct
Set ProductDocument1 = Product1.Parent
Set Product1Products = Product1.Products
Set Part1Dot1 = Product1Products.Item("Part1.1") : Set Part1 = Part1Dot1.ReferenceProduct
Set PartDocument1 = Part1.Parent
Set Selection = ActiveProductDocument.Selection

Another Selectionobject, such as:

 Set ProductDocument2Selection = ProductDocument2.Selection

Set ProductDocument1Selection = ProductDocument1.Selection
Set PartDocument1Selection = PartDocument1.Selection

(lets take ProductDocument2Selection for example) can only be used if, among the different Window , there is at least one whose root Document is ProductDocument2 . Otherwise, results are unpredictable. 



Desconectado/a

Visto por última vez: Hace 2 días 4 horas

se unió: 02/10/2008 - 13:19

Posts:

Para que la macro se pare y te pida seleccionar un elemento deberia de poner

Dim selection1 As Selection

Set selection1 = CATIA.ActiveDocument.Selection -> definir la selección

Dim oInputType(0)

oInputType(0) = "Product" ->para definir que tipo de elemento quieres seleccionar

Dim oStatus

oStatus = selection1.SelectElement2(oInputType, "Escribir aqui Titulo que parece en la barra de mensajes inferior", False) -> para pedir la selección y que muestre un mensaje

El elemento selecionado se graba la en la variable oStatus 

Saludos