Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Ilogic Change Parameter in any Part that is not a component

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
art_turner
607 Views, 4 Replies

Ilogic Change Parameter in any Part that is not a component

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

 

4 REPLIES 4
Message 2 of 5
jdkriek
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
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 3 of 5
art_turner
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.

 

 

 

 

Message 4 of 5
MegaJerk
in reply to: art_turner

Perhaps multiplying it would fix the problem

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


If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
Message 5 of 5
art_turner
in reply to: MegaJerk

here it is

 

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

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report