Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

C++ vs iLogic

Anonymous

C++ vs iLogic

Anonymous
Not applicable

Hello,

 

I took a semester of C++ (Non-Believers) last semester in school and am currently interning for a company. I've discovered iLogic and used some very simple iLogic for rounding and computing some dimensions.

 

I'm wondering how closely C++ and iLogic compare... I notice the if... Then.. End If... tab as well as while, return, exit, etc; all terms that refresh my memory, but I would have to relearn.  I wasn't very good at C++, and am wary of throwing myself into this and not being able to figure it out.

 

My current goal would be something along the lines of..

 

if "A" = "Exclude";

   X = "--";

   if "B" = "Exclude";

       Y = "--";

       if "C" = "Exclude";

           Z = "--";

       else Z = ThirdDistance;

   else Y = SecondDistance;

else X = FirstDistance;

 

return 0;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

A, B, C are Include/Exclude in an iAssembly.

X, Y, Z are Column Headings in a 

FirstDistance, SecondDistance, ThirdDistance are Parameter names in iAssembly

 

0 Likes
Reply
Accepted solutions (1)
789 Views
3 Replies
Replies (3)

Mark.Lancaster
Consultant
Consultant

@Anonymous

 

As far as I know iLogic is more closely represent by VB or .net programming..  However I wall tag @Curtis_Waguespack for his input.  Also when it comes to Inventor iLogic or custom programming there's a separate forum for that and its located here: https://forums.autodesk.com/t5/inventor-customization/bd-p/120

Mark Lancaster


  &  Autodesk Services MarketPlace Provider


Autodesk Inventor Certified Professional & not an Autodesk Employee


Likes is much appreciated if the information I have shared is helpful to you and/or others


Did this resolve your issue? Please accept it "As a Solution" so others may benefit from it.

Anonymous
Not applicable

iLogic Question:

 

I would also like to set a variable to equal "--" under some conditions.

 

Of course, it is currently a Number parameter and I would need a String Parameter to get it to output "--"

 

I know in C++ there is a syntax that can temporarily change a variable to a string, how about Inventor?

 

Here is the most pertinent part of the code:

 

SyntaxEditor Code Snippet

If ThirdDist > 1 Then
inc = .5 ' rounding increment ( .125, .25, .5, etc)
X = Round(Round(L-G_,4) / inc) * inc
Y= Round(Round(L-F_-X,4) / inc) * inc
Z= Round(Round(L-E_-X-Y,4) / inc) * inc
Else 
X = "--"
Y = "--"
Z = "--"
End If

 

0 Likes

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @Anonymous,


As Mark.Lancaster mentioned iLogic is a based in VB.net.

 

Here is a resource link that might be helpful:

https://www.autodesk.com/developer-network/platform-technologies/inventor/overview

 

Also just as a tip, you can search and ask programming questions of this type on the Inventor Customization forum :
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120

 

As for your question, assuming that X, Y and Z are local variable and not parameters, then you can set them to be whatever data type you want. However, using those variables later might cause issue if you mix data types.

 

If "--" is just meant to be a blank value,  and you are setting a string or local variable in your code to be blank, then you might consider using "" as well.

 

If X, Y, and X are a numeric data type such as a Double, then you might need to use:

 

X = Nothing
Y = Nothing
Z = Nothing

 

If you have a numeric Parameter and set it to Nothing, it gets set to zero, which might or might not work for your needs. If it is a model parameter setting it to value can often cause a sketch dimension to flip and go in the opposite direction when it is set to zero and then set back to a positive number, so there are ways to deal with that, that involve creating work planes, which are projected into the sketch, and then driaving the work plane to update the projected geometry in the sketch.

 

But I'm sort of guessing at what you might be trying to do, so a more complete explanation of your goals with the code, and even some example files attached to a new topic on the Inventor Customization forum might get you a more direct answer.

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