×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

CatScript - Copy string to clipboard
2

CatScript - Copy string to clipboard

CatScript - Copy string to clipboard

(OP)
Is there any option to copy a string value to clipboard.

RE: CatScript - Copy string to clipboard



CODE -->

Sub Copy_to_Clipboard()

sString = "Paste To Clipboard"

Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("clip")

Set oWrite = oExec.stdIn

oWrite.WriteLine sString
oWrite.Close

End Sub 

______

Alex ,

RE: CatScript - Copy string to clipboard

(OP)
Thanks Alex for the code. I am getting this error:

http://files.engineering.com/getfile.aspx?folder=f...



Sub CATMain ()

Dim CATProdDoc As ProductDocument
Copy_to_Clipboard()

End Sub

Sub Copy_to_Clipboard()

sString = "Paste To Clipboard"

Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("clip")

Set oWrite = oExec.stdIn

oWrite.WriteLine sString
oWrite.Close

End Sub

RE: CatScript - Copy string to clipboard

(OP)
Well, I have commented out Types, as I run CATIA on Windows (not UNIX), so the code is running fine now!

Sub CATMain ()

Dim CATProdDoc 'As ProductDocument
Copy_to_Clipboard()

End Sub

Sub Copy_to_Clipboard()

sString = "Paste To Clipboard"

Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("clip")

Set oWrite = oExec.stdIn

oWrite.WriteLine sString
oWrite.Close

End Sub

RE: CatScript - Copy string to clipboard

Hi,

Because I'm to lazy to right click, go in Properties and copy in clipboard from different workbenches and then paste what is in clipboard where I need, I've adapted the upper code to my needs (I need only names of different types of documents or text/dimension values in drawings).

CODE --> CATScript

Sub CATMain()
 
Set oPartDocument = CATIA.ActiveDocument
Set oSelection = oPartDocument.Selection
oSelection.Clear

Dim oInputType(0)
Dim oStatus

Dim MySelection3 As Object
Set MySelection3 = oPartDocument.Selection
Dim inputObjectType(0) As Variant
InputObjectType(0) = "AnyObject"
Dim Result As String
Result = MySelection3.SelectElement2(InputObjectType, "Select a dimesion/text in 2D, or a Body/CATPart/CATProduct in 3D ", False)
Set mySelection = oSelection.Item(1).Value
Dim s 'As String
Dim strToLeft 'As String
s = mySelection.Name
strToLeft = Split(s,".")(0) 

Set mySelection = oSelection.Item(1).Value
' Put it back to the clipboard
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("clip")
Set oIn = oExec.stdIn

If strToLeft = "Dimension" Then
oIn.WriteLine mySelection.GetValue.Value
oIn.Close

ElseIf strToLeft = "Text" Then
oIn.WriteLine mySelection.Text
oIn.Close

ElseIf TypeName(MySelection3.Item(1).Value) = "Part" Then
oIn.WriteLine mySelection.Name
oIn.Close

ElseIf TypeName(MySelection3.Item(1).Value) = "Product" Then
oIn.WriteLine mySelection.Name
oIn.Close

ElseIf TypeName(MySelection3.Item(1).Value) = "Body" Then
oIn.WriteLine mySelection.Name
oIn.Close

ElseIf TypeName(MySelection3.Item(1).Value) = "Document" Then
oIn.WriteLine mySelection.Name
oIn.Close

End If

End Sub 

Regards
Fernando

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources