Two diameters... non iLogic solution?

Two diameters... non iLogic solution?

oransen
Collaborator Collaborator
650 Views
4 Replies
Message 1 of 5

Two diameters... non iLogic solution?

oransen
Collaborator
Collaborator

I have a cylinder with a diameter DiamAtt and it has some material taken away by another cylinder, with a diameter of DiamColl. Here's a picture:

 

Two-diameters.png

 

So when DiamColl or DiamAtt changes Dcoll is calculated.

 

I have the iLogic to calculate Dcoll:

 

Dim RagColl as Double
Dim RagAtt As Double
RagColl = DiamColl/2.0
RagAtt = DiamAtt/2.0
If RagAtt < RagColl Then
    Dcoll = Sqrt((RagColl*RagColl) - (RagAtt*RagAtt))
Else
    Dcoll = 0.0 
End If 

This works, but the triggering of the rule seems a bit hit and miss. So my question is:

 

Is there a way of achieving this without iLogic but directly inside the parameter formula column?

 

TIA!

 

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

MechMachineMan
Advisor
Advisor
Accepted solution

You better believe it.

 

https://knowledge.autodesk.com/support/inventor-products/learn-explore/caas/CloudHelp/cloudhelp/2014...

 

 

sign(ragcoll - ragatt) - returns 0 if negative, 1 if positive -- your if statement when used multiplicatively

 

sign(ragcoll*ragcoll -ragatt*ragatt) -- needed because Sqrt(negative number) returns "nan(ind)"

 

THUS:

 

in one line:

 

sign(ragcoll - ragatt)*SQRT((ragcoll*ragcoll - ragat*ragatt)*sign(ragcoll*ragcoll-ragatt*ragatt))

 

Returns 0 =  0 * SQRT((ragcoll*ragcoll - ragat*ragatt)*0) if ragcoll < ragatt

returns SQRT((ragcoll*ragcoll - ragat*ragatt) =  1 * SQRT((ragcoll*ragcoll - ragat*ragatt)*1 if ragcoll > ragatt

 

 

Also, be careful of your units.

 


--------------------------------------
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 3 of 5

CattabianiI
Collaborator
Collaborator
Accepted solution

Try this:

Cattura.PNG

 

sign does the work of your If

abs avoids the square root on negative numbers

 

sign(RagColl - RagAtt)
sqrt(abs((RagColl*RagColl) - (RagAtt*RagAtt))) * ifRes

Anyway, for your iLogic code, make sure you haven't checked the "Don't run automatically" in the iLogic options.

Message 4 of 5

CattabianiI
Collaborator
Collaborator

I just read the @MechMachineMan's answer that get also the sign of the argument of sqrt, and it clearly works, but if RagColl is less than RagAtt, Dcoll is equal to -0, yeah don't worry and treat that -0 as zero, but getting negative sign by the square root can be weird.

Message 5 of 5

oransen
Collaborator
Collaborator

Thanks all for you help!

0 Likes