Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro to make user select an active window

Status
Not open for further replies.

zelym13

Industrial
Jul 11, 2012
9
US

Hello,

I am looking to create a macro that copies and pastes an item from one document to the other. The problem I am having is having the user select their active window. Right now the code specifies which document to paste in. I am looking for code that prompts the user to select their window they want it to be pasted in.

Thanks

Sub CATMain()

Dim documents1 As Documents
Set documents1 = CATIA.Documents

Dim partDocument1 As PartDocument
Set partDocument1 = documents1.Open("Test Model")

Set partDocument1 = CATIA.ActiveDocument

Dim selection1 As Selection
Set selection1 = partDocument1.Selection

selection1.Clear

Dim part1 As Part
Set part1 = partDocument1.Part

Dim hybridBodies1 As HybridBodies
Set hybridBodies1 = part1.HybridBodies

Dim hybridBody1 As HybridBody
Set hybridBody1 = hybridBodies1.Item("Subdivisions")

Dim hybridShapes1 As HybridShapes
Set hybridShapes1 = hybridBody1.HybridShapes

Dim hybridShapeThickness1 As HybridShapeThickness
Set hybridShapeThickness1 = hybridShapes1.Item("Test Surface")

selection1.Add hybridShapeThickness1

selection1.Copy

Dim windows1 As Windows
Set windows1 = CATIA.Windows

Dim specsAndGeomWindow1 As SpecsAndGeomWindow
Set specsAndGeomWindow1 = windows1.Item("PART1")

specsAndGeomWindow1.Activate

Dim partDocument2 As PartDocument
Set partDocument2 = CATIA.ActiveDocument

Dim selection2 As Selection
Set selection2 = partDocument2.Selection

selection2.Clear

Dim part2 As Part
Set part2 = partDocument2.Part

selection2.Add part2

selection2.Paste
 
Replies continue below

Recommended for you

Hi,

Probably you will need to use catvba with a form showing a dropdown list. In that list you can pick your window name...otherwise if you cannot use catvba you have to get all CATIA windows, show the name to user and let him choose the right window (and in catvba should be same procedure but much nicer :) ).



Regards
Fernando

 
Yeah I am using a form for them to choose which part they want copied and pasted. Just having a tough time figuring out how to make a window active by selection.

I am probably going to have the macro create a new document and have it paste into there so the macro can work consistently. This way I wont have to worry about the user selecting an active window it will just create a new one for them.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top