iLogic find and change similar iPart memeber's

iLogic find and change similar iPart memeber's

Log0ut
Enthusiast Enthusiast
572 Views
3 Replies
Message 1 of 4

iLogic find and change similar iPart memeber's

Log0ut
Enthusiast
Enthusiast

I have ipart components in my assembly: iPart_member1:1; iPart_member1:2; iPart_member1:3 ...

Now i want to find and change all iPart_member1's to iPart_member2

 

Simple code be like that:

iPart.ChangeRow("iPart_member1:1", "iPart_member2.ipt")

iPart.ChangeRow("iPart_member1:2", "iPart_member2.ipt")

iPart.ChangeRow("iPart_member1:3", "iPart_member2.ipt")

...

 

Is there a way to do it automatically?

0 Likes
Accepted solutions (1)
573 Views
3 Replies
Replies (3)
Message 2 of 4

johnsonshiue
Community Manager
Community Manager

Hi! I am sorry I don't get what you meant by "automatically". The iLogic rule should help you execute the commands instead of manually changing the members.

Many thanks!

 



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
0 Likes
Message 3 of 4

Log0ut
Enthusiast
Enthusiast

I mean that code reads all 'iPart_member1's in my assembly and change them to iPart_member2.ipt

 

I found that i cant do it like that:

Component.Replace("iPart_member1:1", Lpath & "iPart_member2.ipt", True)

 and this is allmost solution for my problem..

 

But if somehow "iPart_member1:1" gonna be deleted, then this code stops working. Although there are still "iPart_member1:2", "iPart_member1:3"...

 

How i can find "iPart_member1:(?)"

 

0 Likes
Message 4 of 4

JhoelForshav
Mentor
Mentor
Accepted solution

Hi @Log0ut 

If i understand correctly you want to replace the components if their name contains "iPart_member1:"?

Then something like this should do the trick 🙂

 

For Each oOcc As ComponentOccurrence In ThisDoc.Document.ComponentDefinition.Occurrences
If oOcc.Name.Contains("iPart_member1:")
Component.Replace(oOcc.Name, Lpath & "iPart_member2.ipt", True)
Exit For
End If
Next