×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

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!

*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

Catia v5 remove of broken publication with macro

Catia v5 remove of broken publication with macro

Catia v5 remove of broken publication with macro

(OP)
Hello every one,

It happend many times that I receive Catpruducts where somebody has deleted published element but didn't remove linked publication.
And of course Catia shows it as broken publication and I got problem with some checks.
I want to find and remove automatically broken publication from my Catparts.
I can find publications with macro but I don't know how to write in macro following things:

- open from Tools -> Publications window
- select publications with status "no element" and remove it

Can anybody help me??
thanks in advance!



RE: Catia v5 remove of broken publication with macro

hello, this will give you the publication item:

Dim num_of_publ_existing As Integer
num_of_publ_existing = MyPart.Parent.Product.Publications.count

For k = 0 To MyPart.Parent.Product.Publications.count - 1
PubName = MyPart.Parent.Product.Publications.Item(k + 1).name
Set PubRef = MyPart.Parent.Product.Publications.Item(PubName).Valuation
msgbox PubRef.DisplayName
Next
...
so PubRef.DisplayName contains the published name. If there is nothing there, then it is just empty i.e "".
and then you can call a function that removes that element.

Function RemovePublication(MyPartProduct, MyElement)
MyPartProduct.Publications.Remove (MyElement)
End Function

regards,
LWolf

RE: Catia v5 remove of broken publication with macro

(OP)
Thanks for your answer LWolf!
Unfortunatelly my knowledge of catia scripting is not enough to implement your solution into my code.
Could you help me?
My code below:

Sub CATMain()


Dim foundPublications() As Publication

Dim iNbPublications ' As Integer

Dim iPublication ' As Integer


iNbPublications = 0

ReDim foundPublications(iNbPublications) As Publication

Dim oSel As Selection

Set oSel = CATIA.ActiveDocument.Selection


oSel.Search "CATAsmSearch.Product,all"


Dim iProduct ' As Integer

Dim foundProduct As Product

For iProduct = 1 To oSel.Count

Set foundProduct = oSel.Item(iProduct).Value


Dim productPublications As Publications

Set productPublications = foundProduct.Publications

For iPublication = 1 To productPublications.Count

ReDim Preserve foundPublications(iNbPublications) As Publication

Set foundPublications(iNbPublications) = productPublications.Item(iPublication)

iNbPublications = iNbPublications + 1

Next

Next


oSel.Clear


For iPublication = 1 To iNbPublications

Dim publishedReference As Reference

Set publishedReference = foundPublications(iPublication - 1).Valuation

oSel.Add publishedReference


Dim publishedElement As AnyObject

Set publishedElement = oSel.Item(iPublication).Value

MsgBox "Found published element!" & vbCr & "Name (Type): " & publishedElement.Name & "(" & TypeName(publishedElement) & ")"

Next


End Sub




regards
Pawel Chil

RE: Catia v5 remove of broken publication with macro

(OP)
Thank you HarunMusic for great macro!!!
I have removed lines 36 and 38, otherwise it doesn't remove any element(I think because already selected publications have just ordinary name not "" like condition in if ).
Without these lines works perfectly!
Thanks a lot!

RE: Catia v5 remove of broken publication with macro

Hmm i tested in my environment all was good, are you sure it will not delete all publications? That If statement allow to delete only with broken link? I use CATIA V5-6 2016. It can also be to the version of CATIA.

RE: Catia v5 remove of broken publication with macro

(OP)
I use the some Catia, maybe there are some differences because of Service Pack, Hotfix or Build Number?
I have Service Pack 3, Build Number 26, Hotfix 42.

RE: Catia v5 remove of broken publication with macro

Hmm I don't know, but it works for you, that's important :)

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! Already a Member? Login


Resources

Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close