Inventor Customization

Inventor Customization

Reply
Distinguished Contributor
art_turner
Posts: 218
Registered: ‎04-01-2008
Message 1 of 5 (342 Views)
Accepted Solution

Ilogic Change Parameter in any Part that is not a component

342 Views, 4 Replies
10-01-2013 02:43 PM

can you tell what i want to do here. the commented code does not work.

 

i want to be able to open a part and change its size parameters before i open the assembly. this code will run as an external rule in a new empty file. 

 

if i can do it without opening the part, that is even better.

 

'test can i open a part, change a param, then close part

Dim fname As String

fname ="C:\Workspace\my_prog\chan\F_BB_L.ipt"

 

Dim pDoc as PartDocument = ThisApplication.Documents.Open(fname,False)

pDoc  = ThisApplication.Documents.Open(fname)

 

' these are just attempts to find a syntax that works

' i need the method to change the parameter

 

 'param = pDoc.PartComponentDefinition.Parameter.Param("TKNS")

 'pdoc.parameter.Param("TKNS") = 8

 

pdoc.Save

pdoc.Close

 

Here you go:

 

Dim fName As String = "C:\Workspace\my_prog\chan\F_BB_L.ipt"
Dim pDoc as PartDocument = ThisApplication.Documents.Open(fName, False)
pDoc.ComponentDefinition.Parameters.Item("TKNS2").Value = 8
pDoc.Update
pDoc.Save
pDoc.Close 
*Expert Elite*
jdkriek
Posts: 545
Registered: ‎03-29-2007
Message 2 of 5 (320 Views)

Re: Ilogic Change Parameter in any Part that is not a component

10-01-2013 08:37 PM in reply to: art_turner

Here you go:

 

Dim fName As String = "C:\Workspace\my_prog\chan\F_BB_L.ipt"
Dim pDoc as PartDocument = ThisApplication.Documents.Open(fName, False)
pDoc.ComponentDefinition.Parameters.Item("TKNS2").Value = 8
pDoc.Update
pDoc.Save
pDoc.Close 
Jonathan D. Kriek

Autodesk Inventor Certified Expert
Microsoft Certified Application Developer
_____________________________________________________
Did I help you? Please choose Accept as Solution or Kudos below
Distinguished Contributor
art_turner
Posts: 218
Registered: ‎04-01-2008
Message 3 of 5 (306 Views)

Re: Ilogic Change Parameter in any Part that is not a component

10-02-2013 06:22 AM in reply to: jdkriek

thanks!

 

but,

 

gives result in cm,

the parameter is in inches.

 

8 / 0.39370 gives a result in inches, with errors in the 5th place,

 

what is the standard way to input 8"?

 

thanks again.

 

 

 

 

Valued Mentor
MegaJerk
Posts: 281
Registered: ‎01-26-2011
Message 4 of 5 (287 Views)

Re: Ilogic Change Parameter in any Part that is not a component

10-03-2013 04:44 AM in reply to: art_turner
Perhaps multiplying it would fix the problem

pDoc.ComponentDefinition.Parameters.Item("TKNS2").​Value = (8*2.54)
--------------------------------------------------------------------------------------

If my solution seems to remedy your problem, please press the Accept Solution button, -
as it increases my power levels and will eventually help to elevate me towards outer space.

Check out my iLogic injection tool here : http://goo.gl/ce1Qg
--------------------------------------------------------------------------------------
Distinguished Contributor
art_turner
Posts: 218
Registered: ‎04-01-2008
Message 5 of 5 (268 Views)

Re: Ilogic Change Parameter in any Part that is not a component

10-03-2013 06:50 PM in reply to: MegaJerk

here it is

 

pDoc.ComponentDefinition.Parameters.Item("TKNS").Expression = "8 in"

 

 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.