I want to update values in a closed ipt, iam, and idw from an open idw

I want to update values in a closed ipt, iam, and idw from an open idw

bmc_dowell
Participant Participant
390 Views
4 Replies
Message 1 of 5

I want to update values in a closed ipt, iam, and idw from an open idw

bmc_dowell
Participant
Participant
BASEDIRECTORY = "G:\Pipes\AUTOMATION FILES\"
BASEFILE = "10PIPE.ipt"
Dim UPDATEFILE As String = BASEDIRECTORY & BASEFILE
Dim pDoc As PartDocument = ThisApplication.?????
Dim pDoc.ComponentDefinition.Parameters.Item("DIAMETER").Value = DIAMETER 'PARAMETER IN IDW

This controller is setting parameters in around 10 of 200 parts and assemblies
then I plan to copy and rename the idws, parts, and assemblies to a new folder

(as well as dump the new assemblies into a new assembly)
I have done this from an assembly to parts in the assembly, but never to a closed assembly

 

Thanks for any help

 

 

0 Likes
Accepted solutions (1)
391 Views
4 Replies
Replies (4)
Message 2 of 5

bmc_dowell
Participant
Participant

 

BASEDIRECTORY = "G:\Pipes\AUTOMATION FILES\"
BASEFILE = "10PIPE.ipt"
Dim updateone As Inventor.PartDocument = ThisApplication.Documents.ItemByName(BASEDIRECTORY & BASEFILE) updateone.ComponentDefinition.Parameters.Item("DIAMETER").Value = DIAMETER

think this is the way but it isn't working yet

 

0 Likes
Message 3 of 5

A.Acheson
Mentor
Mentor
Accepted solution

 

You will need to open it but you can open it with visible set to false. Then update. The drawing will open the part in the background, so really opening it again will just move focus to that document. 

Try This,

BASEDIRECTORY = "G:\Pipes\AUTOMATION FILES\"
BASEFILE = "10PIPE.ipt"
Dim updateone As Inventor.PartDocument =ThisApplication.Documents.Open(BASEDIRECTORY & BASEFILE,False)
updateone.ComponentDefinition.Parameters.Item("DIAMETER").Value = DIAMETER
updateone.Update
updateone.Save

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 4 of 5

bmc_dowell
Participant
Participant

Thanks so much I tried going down this road before but was missing ComponentDefinition
I had done it years ago just couldn't find it

0 Likes
Message 5 of 5

bmc_dowell
Participant
Participant

Just in case someone gets here and it seems a smaller number

BASEDIRECTORY = "G:\Pipes\AUTOMATION FILES\"
BASEFILE = "10PIPE.ipt"
Dim updateone As Inventor.PartDocument =ThisApplication.Documents.Open(BASEDIRECTORY & BASEFILE,False)
updateone.ComponentDefinition.Parameters.Item("DIAMETER").Expression = DIAMETER
updateone.Update
updateone.Save  

 

0 Likes