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

iLogic

Hi my name is George and i am new with inventor.

i am trying to set parameters to a sketch in 2d which we use it in deffernts dimensions where i work.the problem is tha when i choose the smaller part where some holes should disapear i have this part

2018-11-15.png

 

Through i logic a have make this holes "false" but istead it makes them "0  '' and this two dimension appears

GeorgK
in reply to: Anonymous

Hello @Anonymous,

 

please can you provide your code.

 

Georg

Anonymous
in reply to: GeorgK

This is the rule i use:

 

If Width=66 Then
dim7a=False
circle7a=False
numcircle7a= False
discircle7a= False
dim7b= False
circle7b= False
numcircle7b= False
discircle7b= False

ElseIf Length=2442 And Width<>66 Then
dim7a=372
circle7a=7
numcircle7a=2
discircle7a=600
dim7b=321
circle7b=7
numcircle7b=2
discircle7b=549


ElseIf Length=2289 And Width<>66 Then
dim7a=397
circle7a=7
numcircle7a=2
discircle7a=600
dim7b=244.5
circle7b=7
numcircle7b=2
discircle7b=447.5

ElseIf Length=2136 And Width<>66 Then
dim7a=371.5
circle7a=7
numcircle7a=2
discircle7a=600
dim7b=219
circle7b=7
numcircle7b=2
discircle7b=396.5

ElseIf Length=1983 And Width<>66 Then
dim7a=391.5
circle7a=7
numcircle7a=2
discircle7a=600
dim7b=391.5
circle7b=7
numcircle7b= False
discircle7b= False

ElseIf Length=1830 And Width<>66 Then
dim7a=366
circle7a=7
numcircle7a=2
discircle7a=600
dim7b=315
circle7b=7
numcircle7b= False
discircle7b= False


ElseIf Length=1677 And Width<>66 Then
dim7a=340.5
circle7a=7
numcircle7a=2
discircle7a=498
dim7b=340.5
circle7b=7
numcircle7b= False
discircle7b= False

ElseIf Length=1524 And Width<>66 Then
dim7a=363.8
circle7a=7
numcircle7a=2
discircle7a=549
dim7b=214.6
circle7b=7
numcircle7b= False
discircle7b= False

ElseIf Length=1371 And Width<>66 Then
dim7a=385.5
circle7a=7
numcircle7a= False
discircle7a= False
dim7b=385.5
circle7b=7
numcircle7b= False
discircle7b= False

ElseIf Length=1218 And Width<>66 Then
dim7a=360
circle7a=7
numcircle7a= False
discircle7a= False
dim7b=309
circle7b=7
numcircle7b= False
discircle7b= False

ElseIf Length=1065 And Width<>66 Then
dim7a=283.5
circle7a=7
numcircle7a= False
discircle7a= False
dim7b=283.5
circle7b=7
numcircle7b= False
discircle7b= False

ElseIf Length=912 And Width<>66 Then
dim7a=308.5
circle7a=7
numcircle7a= False
discircle7a= False
dim7b=207
circle7b=7
numcircle7b= False
discircle7b= False

ElseIf Length=759 And Width<>66 Then
dim7a=379.5
circle7a=7
numcircle7a= False
discircle7a= False
dim7b= False
circle7b= False
numcircle7b= False
discircle7b= False

ElseIf Length=606 And Width<>66 Then
dim7a=303
circle7a=7
numcircle7a= False
discircle7a= False
dim7b= False
circle7b= False
numcircle7b= False
discircle7b= False

ElseIf Length=504 And Width<>66 Then
dim7a=252
circle7a=7
numcircle7a= False
discircle7a= False
dim7b= False
circle7b= False
numcircle7b= False
discircle7b= False

ElseIf Length=453 And Width<>66 Then
dim7a=226.5
circle7a=7
numcircle7a= False
discircle7a= False
dim7b= False
circle7b= False
numcircle7b= False
discircle7b= False

ElseIf Length=402 And Width<>66 Then
dim7a=201
circle7a=7
numcircle7a= False
discircle7a= False
dim7b= False
circle7b= False
numcircle7b= False
discircle7b= False

ElseIf Length=359 And Width<>66 Then
dim7a=179.5
circle7a=7
numcircle7a= False
discircle7a= False
dim7b= False
circle7b= False
numcircle7b= False
discircle7b= False

End If
Thank you for your time

DRoam
in reply to: Anonymous

@Anonymous, it appears to me like you're trying to sketch your part like you would in AutoCAD, and have your iLogic control your sketch by turning the "holes" (sketched circles) on and off. Is that correct?

 

If so, you'll be much better off extruding your part into a 3D solid, and using the Hole and Pattern tools to make the holes. Then you can use the iLogic to suppress the Hole features.

 

iLogic can automate sketches but it's much more complicated, and isn't necessary in this case. Pretty much the only time you should need to use iLogic to control a sketch is when you're using iLogic to create a part from scratch, such as for a configurator.

 

90% of the time, you'll be using iLogic to control parameters (dimensions), and the suppression of 3D features. There's no need to suppress or create 2D sketch features like circles.

 

Hope that helps.

DRoam
in reply to: DRoam

I'm not sure what version of Inventor you have, but if you have 2017 or newer, you can take a look at the attached example part that demonstrates how to use iLogic to control the number/suppression of holes.

 

When you open the part, it should open a control form. Drag the slider back and forth to see it adjust the number of holes and their spacing. Below 1000 mm, it suppresses them altogether.

 

Hope this helps.

Anonymous
in reply to: DRoam

Ok..I see what you propose and i will try it in 3d...but the reason i want to set paramters to this piece is because i am a cnc programmeran and i want to make all the cam programs through inventor vba.if i made the part 3d you think it will be a problem???

JamieVJohnson2
in reply to: Anonymous

FYI, when you say

dim7a=False, you are telling Inventor to use the Boolean True\False.  It sees that the value needs a numeric (double) so it automatically converts the Boolean to its bit (tiny integer) value 0,1, then stores the False equivalent (0) to your variable.  Turning it to 0 does not remove it, as you can tell. 

 

DRoam is right, there are easier methods from the 3D modeling environment.  To address the 3D issue, you could model it in 3D and then project the modeled geometry back to a single 2D sketch (like a completed view/flat pattern) that you update and use for your CNC.

 

However, with iLogic (better to use VB.Net, with Visual Studio at this level) and a LOT more setup and coding, you can create a sketch with holes, then add attributes to the circles (via code), then save that sketch for reuse as a template, where you can find the circles that have your tagged attributes and delete them via code (or set construction).

 

Another method using all parameters is to create a pattern in a sketch.  Component patterns (arrays) can take a single item (like your hole circle) and make it many (square or circlular).  The neat part is the pattern's count is a parameter you can label, find and edit.  The bad part is there must at least be 1 or it will not work.  Also you could use the parameter of the pattern to chase the sketch objects back to the original circle and set its construction mode on/off as you need.  If you dimensioned the first hole's position, you could chase that back to the circle too.

 

Is it possible, yes.  Do you want to work that hard?  The journey definitely becomes its own reward when you gain the tools and skills to knock out problems like these in a flash.

 

jvj
Anonymous
in reply to: JamieVJohnson2

Actually I have no choice if am gonna do it...its my exercise for my degree so in a way i am force to... but also is something tha will help me very much in my work.Smiley LOL

 

Thank you very much for the immediate answers an the interest  you show in my problem.... i will try your solution and i will inform you if its ok or i will post here for more answers(please help Smiley Happy)

 

is there something in here or maybe a video in youtube that would it help me to understand better the ilogic logic??

 

thank you very very much

Anonymous
in reply to: JamieVJohnson2

Thank you very much for the support..i finally set parameters to my sketch and it works perfect...i did as you proposed i 3d mode...now i am going to write the cam files for my cnc machine. i have one more question i am using this code

 

Option Explicit

Sub WriteFile()

Dim Doc As Document
Set Doc = ThisApplication.ActiveDocument

Dim oParam As Parameters
Set oParam = ThisApplication.ActiveDocument.ComponentDefinition.Parameters

Dim UserParams As UserParameters
Set UserParams = oParam.UserParameters

Dim oLength As Parameters
Set oLength = oParam.UserParameters(Length)



Open "C:\Users\tso\Desktop\test.txt" For Output As #1 'Open file for output

Write #1, oParam.UserParameters = Length


Close #1 'Close file

End Sub

 

But as you imagine doesn't work..so i want to ask you how can i call the length value in my vba editor?

JamieVJohnson2
in reply to: Anonymous

Two things (one not a real issue).

Non issue first:

You create a UserParams variable and set it, but don't use it.  Instead you blow past it.

Actual issue:

I think your call for .UserParameters(Length) needs quotation marks .UserParameters("Length")

This is assuming you have a user parameter with the name being "Length", your code must specify that is a string.  Otherwise the compiler is looking for a variable called Length from your code, and trying to get its value (which doesn't exist here).

Finally, your specifying to write Length not oLength.  This write method I'm not familiar with, because I learned StreamReader/Writer, and WriteLine methods from .Net.

jvj
Anonymous
in reply to: JamieVJohnson2

Does inventror vba works with the write line method??an if yes can i have an example??