×
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

macro to save selected partsto specified path failed

macro to save selected partsto specified path failed

macro to save selected partsto specified path failed

(OP)
I creat a macro( see bellow) to save selected part to a specified Path but failed. any help will be appreciated.
''''''''''''''''''''
Language = "VBScript"

CATIA.DisplayFileAlerts = False
sub CATMain()
Set cad = CATIA.ActiveDocument
Set sel = cad.Selection
Set prod = cad.Product.Products
Set docs = CATIA.Documents

If sel.count =0 Then
MsgBox "Select parts from tree.", ,msgboxtext
Exit Sub
End If


docPath=InputBox("Enter the Path:")

for i=1 to sel.count

set doc1= docs.item(i)
doc1.saveas docPath & prod.item(i).PartNumber &".CatPart" 'failed here

next

End sub

RE: macro to save selected partsto specified path failed

(OP)
It still doesn't work.How to set Selection in Design Mode?

RE: macro to save selected partsto specified path failed

set doc1= docs.item(i)

this is not linked with sel (your selection) so it will save each doc.item in the open document... this will not take selected part into account

Eric N.
indocti discant et ament meminisse periti

RE: macro to save selected partsto specified path failed

(OP)
To itsmyjob,
thanks for your reply.
Yes,I find a macro in the forum, which can save all items to one folder, but I expect to save selected part to different folder,let say some to Folder A, some to Folder B, bolt and nut to a Fastener Folder, motor and cylinder to purchased part Folder,etc…

The question is how to link docs.item(i) to select parts
Take following as an Example
Product..
|---A
|---A
|---B
|---B
|---C
|---D
|---E

If I select the 5th to 7th parts, ie, C,D, and E, and save this three to a defined folder. I don't know how to link docs.item(i) to selected D and E?
The docs.item(i) can get the filename, I wonder how to get its partnumber or instance name , if its partnumber or instance name are got,I think doc.item(i) can link to selected parts through them.

RE: macro to save selected partsto specified path failed

(OP)
to ferdo,
Sorry to make you misunderstanding.
My purpose is to select some parts( say, part_1 to part_n,see bellow), and save them to a specified folder,for example, E:\wlding_jig\unit_1, which is input in InputBox.
I know this can be realised by saveas one by one, but it's wastetime.
------------------
welding_jig
|--------Unit_1
| |----part_1
| |----part_2
| |----part_2
| |----part_3
| |----part_3
| |----part_4
| .
| |----part_n
| .
| |----bolt_M10x65
| |----Bolt_M8x50
| |----nut_M10
| |----nut_M8
|
|--------unit_2
| |----
|

Thank you any way.



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