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: 

Printed parameter not updated

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
george0621
152 Views, 3 Replies

Printed parameter not updated

george0621
Enthusiast
Enthusiast

I have a code as shown below that changes the value of 2 angular constraints and then prints out 2 parameters. These 2 parameters are driven parameters and are the length of lines between two parts so I can measure the distance between the two parts as the angles change. However, when I run the code, the original parameter is printed and not the updated ones. Is there any way to solve this?

 

Dim A As Integer = 3
Dim X As Integer = 225
Dim Y As Integer = 0

For A = 1 To 10 Step 1
	X = 225 - (A*5)
	Y = 0 + (A*5)
	Constraints.AddAngle("Angle:7", {"253439-L:1", "253394-L:1"}, "Face0", "253392:1", "Face0", X)
	Constraints.AddAngle("50", "Standard:3", "Face0", "253392:2", "Face1", Y)
	InventorVb.DocumentUpdate()
	Parameter.UpdateAfterChange = True
	i = MessageBox.Show(d242 & "          " & d243)	
Next A
0 Likes

Printed parameter not updated

I have a code as shown below that changes the value of 2 angular constraints and then prints out 2 parameters. These 2 parameters are driven parameters and are the length of lines between two parts so I can measure the distance between the two parts as the angles change. However, when I run the code, the original parameter is printed and not the updated ones. Is there any way to solve this?

 

Dim A As Integer = 3
Dim X As Integer = 225
Dim Y As Integer = 0

For A = 1 To 10 Step 1
	X = 225 - (A*5)
	Y = 0 + (A*5)
	Constraints.AddAngle("Angle:7", {"253439-L:1", "253394-L:1"}, "Face0", "253392:1", "Face0", X)
	Constraints.AddAngle("50", "Standard:3", "Face0", "253392:2", "Face1", Y)
	InventorVb.DocumentUpdate()
	Parameter.UpdateAfterChange = True
	i = MessageBox.Show(d242 & "          " & d243)	
Next A
3 REPLIES 3
Message 2 of 4

alexanderboogaard
Enthusiast
Enthusiast
Hi,

Any chance that you send a model so it is clear what you're trying to achieve? Preferably a ZIP.

Kind regards,
Alexander Boogaard
0 Likes

Hi,

Any chance that you send a model so it is clear what you're trying to achieve? Preferably a ZIP.

Kind regards,
Alexander Boogaard
Message 3 of 4

george0621
Enthusiast
Enthusiast
Accepted solution
Hi!

Thanks for taking the time to look at my question but I just managed to solve it.
I had two parameters ( d242 and d243) and I wanted to see their immediate values as I changed the angle between to constrained parts. However, the values of d242 and d243 displayed in message box were always those before the rule ran.

I managed to solve this by using the Parameter() function and assigned d242 and d243 to variable A1 & A2 respectively. Then used that variable as an argument in the MessageBox.Show() function (see code below). This made sure I got the immediate value of d242 and d243.


Dim A As Integer = 3
Dim X As Integer = 225
Dim Y As Integer = 0
Dim A1 As Double = 0
Dim A2 As Double = 0


For I = 0 To 3 Step 1


X = 225 - (A*5)
Y = 0 + (A*5)
Constraints.AddAngle("Angle:7", {"253439-L:1", "253394-L:1"},
"Face0", "253392:1", "Face0", X(I))
Constraints.AddAngle("50", "Standard:3", "Face0", "253392:2",
"Face1", Y(I))

InventorVb.DocumentUpdate()

A1 = Parameter("d242")
A2 = Parameter("d243")

I = MessageBox.Show(A1 & " " & A2)



Next A




0 Likes

Hi!

Thanks for taking the time to look at my question but I just managed to solve it.
I had two parameters ( d242 and d243) and I wanted to see their immediate values as I changed the angle between to constrained parts. However, the values of d242 and d243 displayed in message box were always those before the rule ran.

I managed to solve this by using the Parameter() function and assigned d242 and d243 to variable A1 & A2 respectively. Then used that variable as an argument in the MessageBox.Show() function (see code below). This made sure I got the immediate value of d242 and d243.


Dim A As Integer = 3
Dim X As Integer = 225
Dim Y As Integer = 0
Dim A1 As Double = 0
Dim A2 As Double = 0


For I = 0 To 3 Step 1


X = 225 - (A*5)
Y = 0 + (A*5)
Constraints.AddAngle("Angle:7", {"253439-L:1", "253394-L:1"},
"Face0", "253392:1", "Face0", X(I))
Constraints.AddAngle("50", "Standard:3", "Face0", "253392:2",
"Face1", Y(I))

InventorVb.DocumentUpdate()

A1 = Parameter("d242")
A2 = Parameter("d243")

I = MessageBox.Show(A1 & " " & A2)



Next A




Message 4 of 4

alexanderboogaard
Enthusiast
Enthusiast

Glad you solved it.

Just be careful with reusing variables. You use 'I' for iterating, but also for the messagebox. Also you don't need to fill the variables with a value if you refill them in the code. Just declaring them is enough:

Dim A As Integer
Dim X As Integer
Dim Y As Integer
Dim A1 As Double
Dim A2 As Double

But at least it works.


Kind regards,
Alexander Boogaard

Glad you solved it.

Just be careful with reusing variables. You use 'I' for iterating, but also for the messagebox. Also you don't need to fill the variables with a value if you refill them in the code. Just declaring them is enough:

Dim A As Integer
Dim X As Integer
Dim Y As Integer
Dim A1 As Double
Dim A2 As Double

But at least it works.


Kind regards,
Alexander Boogaard

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

Post to forums  

Autodesk Design & Make Report