iLogic Motion

iLogic Motion

Anonymous
Not applicable
1,490 Views
11 Replies
Message 1 of 12

iLogic Motion

Anonymous
Not applicable

Hello all!

 

I have attached a screencast to show what my issue is.

What I have, is a hydraulic cylinder assembly set up to extend & retract using the code:

 

Dim i As Double 'starting value

Dim iLimit As Double = 96 'top range of parameter

Dim iStep As Double = 0.3 'increment to increase by

For i = 53.75 To  iLimit Step iStep

    Parameter("3300393:1", "Stroke") = i

    RuleParametersOutput() 'required to update the parameter

    InventorVb.DocumentUpdate()

    ThisApplication.ActiveView.Update()

 

Next

 

 

I then use this cylinder in an assembly as shown in the screencast. I use iLogicVb.RunRule("") to run the rule in the cylinder from the trailer assembly. As you can see, the cylinder will fully extend before the body will be affected.

Is there a way to tell the body to follow the cylinder throughout the entirety of the stroke?

 

Thanks!

0 Likes
Accepted solutions (1)
1,491 Views
11 Replies
Replies (11)
Message 2 of 12

Anonymous
Not applicable

 

0 Likes
Message 3 of 12

MechMachineMan
Advisor
Advisor

I would venture to guess that all of your Inventor VB Update calls are ONLY affecting your cylinder model since that is the document the rule is being ran from.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 4 of 12

Curtis_Waguespack
Consultant
Consultant

Hi DanielPenner,

 

See if the attached example files (Inventor 2015) help.

 

The code in the top level assembly is this:

 

Dim i As Double 'starting value
Dim iLimit As Double  'top range of parameter
Dim iStep As Double 'increment to increase by

'get start
i =  Parameter("822_0:1", "Stroke")

If i <> 0 Then
	 iStep = -0.5
	 iLimit = 0
Else
	iStep = 0.5
	iLimit = 18
End If

For i = i To  iLimit Step iStep
	Parameter("822_0:1", "Stroke") = i
	RuleParametersOutput() 'required to update the parameter
	InventorVb.DocumentUpdate()
	ThisApplication.ActiveView.Update()
Next


 

 

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

EESignature

0 Likes
Message 5 of 12

MechMachineMan
Advisor
Advisor

 

I would try something along these lines:

 

Dim oDoc As Document
oDoc = ThisDoc.Document

Dim i As Double 'starting value
Dim iLimit As Double = 96 'top range of parameter
Dim iStep As Double = 0.3 'increment to increase by

Dim oSubDoc As Document
oSubDoc = ThisApplication.Documents.ItemByName("C:\File.ipt")

For i = 53.75 To  iLimit Step iStep
    oSubDoc.Parameters("Stroke").Expression = i & " in."
    oSubDoc.Update()
    oDoc.Update()
    ThisApplication.ActiveView.Update()
Next

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 6 of 12

Anonymous
Not applicable

Hello Curtis!

 

This method does work, however I was hoping to have minimal code on the parent level. I would like to have it all on the cylinder level to make it more re-useable. The intention with the cylinder is that I can drop it into another parent level assembly and be able to simply extend it. It may not be an issue to do it this way with our single stage cylinder, however I'm hoping to use the same technique in assemblies with 5 stage cylinders as well which would make it much more complicated.

0 Likes
Message 7 of 12

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi DanielPenner,

 

I think I would make this an External rule then. That was it doesn't reside in the assembly or the sub assembly, but can be run as needed whenever the cylinder sub assembly is present.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

EESignature

0 Likes
Message 8 of 12

Anonymous
Not applicable

Hey Curtis

 

Thanks for that idea, it totally slipped my mind to try that.

Just curious, with this code I can set the step value, but there is no speed or rate setting. Is there a way to access that? Increasing the step value does increase the speed, however it also reduces the accuracy.

 

Dim i As Double 'starting value

Dim iLimit As Double =50 'top range of parameter

Dim iStep As Double = 0.1 'increment to increase by

For i =15 To  iLimit Step iStep

    Parameter("3300393:1", "Stroke") = i

    RuleParametersOutput() 'required to update the parameter

    InventorVb.DocumentUpdate()

    ThisApplication.ActiveView.Update()

0 Likes
Message 9 of 12

MechMachineMan
Advisor
Advisor

SyntaxEditor Code Snippet

System.Threading.Thread.Sleep(1000) 'where the parameter (1000) is in ms

 


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 10 of 12

Anonymous
Not applicable

Adjusting this simply delayed the rule from running, it did not speed up the motion itself...

0 Likes
Message 11 of 12

Curtis_Waguespack
Consultant
Consultant

@Anonymous wrote:

Hey Curtis

 

Thanks for that idea, it totally slipped my mind to try that.

Just curious, with this code I can set the step value, but there is no speed or rate setting. Is there a way to access that? Increasing the step value does increase the speed, however it also reduces the accuracy.

 


Hi DanielPenner,

 

You can add a sleep line to slow it down. But to speed it up I think the step value is the only way.

 

You could do something like this example to create a "speed curve" for the step value, which in this case run the middle 80% of the travel 2x faster (2x larger steps), but the starting and ending steps are at 1x, so the end position is more accurate. See attached 2015 files.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

Dim i As Double 'starting value
Dim iLimit As Double  'top range of parameter
Dim iStep As Double 'increment to increase by

'total travel 
oTravel = 18

'comment/ uncomment to add/remove a delay
oDelay = 0
'oDelay = 100 'in millseconds

'get resting value
i =  Parameter("822_0:1", "Stroke")

'determine direction to run
If i <> 0 Then 'run down
	 iStep = -0.25
	 iLimit = 0
	iRange1 = oTravel - (oTravel * 0.1) '10% of the travel
	iRange2 = oTravel - (oTravel * 0.8) '80% of the travel
Else 'run up
	iStep = 0.25
	iLimit = oTravel
	iRange1 = oTravel * 0.1 '10% of the travel
	iRange2 = oTravel * 0.8 '80% of the travel
End If

'first 10% of travel
For i = i To  iRange1 Step iStep
	System.Threading.Thread.Sleep(oDelay)
	Parameter("822_0:1", "Stroke") = i
	RuleParametersOutput() 'required to update the parameter
	InventorVb.DocumentUpdate()
	ThisApplication.ActiveView.Update()
Next

'middle 80% of travel
For i = i To  iRange2 Step iStep * 2 'run at 2x the speed
	System.Threading.Thread.Sleep(oDelay)
	Parameter("822_0:1", "Stroke") = i
	RuleParametersOutput() 'required to update the parameter
	InventorVb.DocumentUpdate()
	ThisApplication.ActiveView.Update()
Next

'remainder or travel
For i = i To  iLimit Step iStep
	System.Threading.Thread.Sleep(oDelay)
	Parameter("822_0:1", "Stroke") = i
	RuleParametersOutput() 'required to update the parameter
	InventorVb.DocumentUpdate()
	ThisApplication.ActiveView.Update()
Next

EESignature

0 Likes
Message 12 of 12

MechMachineMan
Advisor
Advisor
Put it inside of your for loop that contains each step to make it pause
there, rather than before running the whole rule.......

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes