iLogic - Flat Pattern Extents to Parameters

iLogic - Flat Pattern Extents to Parameters

jdbrown
Participant Participant
4,322 Views
17 Replies
Message 1 of 18

iLogic - Flat Pattern Extents to Parameters

jdbrown
Participant
Participant

I'm currently working on a script to run in new and old parts in inventor 2020 that I need to have the flat pattern area of a sheet metal part in the iProperties but without the unit string in it. I would like to be able to have this where it auto updates the iProperty when the model changes but I'm struggling to get this to work. I've tried making them parameters and exporting them but I cant get that to auto update when the model changes, and when I try to set the iProperty to <Sheet Metal Area> it adds IN2 to the end of the value and the ERP software that we are trying to implement won't accept that as the value. I don't have a problem with adding a rule to the parts but I would like to avoid that if possible.

0 Likes
Accepted solutions (1)
4,323 Views
17 Replies
Replies (17)
Message 2 of 18

WCrihfield
Mentor
Mentor

Definately sounds doable.  There is actually already a built-in iProperty called "Flat Pattern Area" specifically for that, under the "Design Tracking Properties" property set.  You would just have to use the available String editing tools in your Snippets / System / Strings category, to get rid of the Units string at the end.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 18

jdbrown
Participant
Participant

Will this still auto update when there are changes to the model so that the value stays accurate? I'm trying to avoid making me and my coworkers run the script anytime we change the design.

0 Likes
Message 4 of 18

k14348
Advocate
Advocate

Hi,

Use =<Flat Pattern Length> X <Flat Pattern Width> X <Flat Pattern Area>

 

Hope your issue resolved.

 

Regards,

Karth

0 Likes
Message 5 of 18

WCrihfield
Mentor
Mentor

Hi @jdbrown .

@k14348's idea is another possible route you may be able to use.  You wouldn't need to use an iLogic Rule or VBA code to make it work either.  I don't know if you're familliar with this technique, so I'll try to explain.  Basically, within your iProperties dialog box, starting from an empty text entry slot (Like the Title, or Description text box), you can start the text with an "=" equals sign, followed by whatever string of text you want, with some live iProperty links in there wherever you want.  The live iProperty links are defined by encapsulating the name of the iProperty between the less-than & greater-than signs, like this <iProperty_Name>.  When you finish typing and either click Apply or Enter, the string of text will transform, and where you had the live iProperty links, it will be displaying the value of that iProperty.  You will then see an Equation symbol at the right side of that line, indicating this linked status.  Then when you go to edit that line again, it will transform back to showing how you typed it in (unless you select all then start typing which will replace the linked status).    

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 6 of 18

jdbrown
Participant
Participant

I am familiar with this method. It is a part of how I setup my title block for certain parts. The only problem with this method is that is has the unit string in there, which another software we are using won't accept. The software needs a unitless number value. When I've attempted with the =<Sheet Metal Area> it just changes the property to a number value minus the unit string but it loses the formula so it won't update.

0 Likes
Message 7 of 18

k14348
Advocate
Advocate

Use =<Flat Pattern Area> instead of sheetmetal area. U wont get any units. Hope ur issue solved

 

karth

0 Likes
Message 8 of 18

jdbrown
Participant
Participant

Thank you Karth. I was not aware of that particular one. I just tried this out and apparently this will not work for my situation. The software I'm sending this information to accepts that value on the first attempt with that, however it removes the formula and changes it to the calculated value of the formula so it will not update after that. I guess at his point I will need a rule that will auto-run on sheet metal parts to update the value on any model change but that's not something that I can do with my current iLogic knowledge.

0 Likes
Message 9 of 18

WCrihfield
Mentor
Mentor

Those iProperties are built-in and should always be up-to-date, unless you've made modifications to the model without a document update.

However, the equation (whatever it is?) will likely need to be updated using a local iLogic rule, since were dealing with an iProperty instead of a Parameter.   The contents of the local rule can be specified within an external rule, then that same exteral rule can create the local rule with those specifications into your local files fairly easily.  I would probably save the resulting value to a Parameter, then set that parameter to 'Export', and set its 'Custom PropertyFormat' to Number.  That way everytime the parameter updates, it will automatically update the Custom iProperty (same name as the Parameter) it is linked to.  You can also specify within those Custom Property Format, that you don't want the Units String.

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 10 of 18

jdbrown
Participant
Participant

What do I need in my internal rule in order to make it update the parameter on a change to the model? I've got the coding in place to create the necessary parameters. But it just gets the extents at the moment the rule is run and changes the parameter to that. I just don't know how to keep the parameters updated when the model changes.

0 Likes
Message 11 of 18

k14348
Advocate
Advocate

Hi,

   whenever u run this code description value will automatically get updated if it is a sheetmetal part.

Sub Desupdate()

Dim openDoc As AssemblyDocument
Set openDoc = ThisApplication.ActiveDocument
Dim doc As Document
For Each doc In openDoc.AllReferencedDocuments
    If doc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then

        Dim oProp As Property
        Set oProp = doc.PropertySets.Item("Design Tracking Properties").Item("Description")
        oProp.Value = "=<Flat Pattern Length> X <Flat Pattern Width> X <Flat Pattern Area>"
        
    End If
Next

End Sub

 

Karth

0 Likes
Message 12 of 18

WCrihfield
Mentor
Mentor
Accepted solution

Hi @jdbrown .

There are several fairly simple ways to do something like this.

Perhaps the quickest is to add your iLogic rule to the appropriate location within the "Event Triggers".

Manage tab / iLogic panel / Event Triggers.

The next option, and perhaps the better option, is to add a series of dummy variables to the top of your local iLogic rule that are set to be equal to whichever Parameters that you want to use as 'triggers'.  Then every time one of those parameters changes, that rule will run.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 13 of 18

WCrihfield
Mentor
Mentor

If you're using an external rule for this, and you want to be able to do the dummy variable trigger method, I would then recomend adding some code to that rule which automatically creates the local rule within the effected document, that will, in turn,  simply run your external rule, when triggered.  If you need help setting this up, I can help with that.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 14 of 18

jdbrown
Participant
Participant

I think what I'm going to have to do is have an internal rule with a geometry change trigger. I've already setup a few scripts to add local rules and adding the trigger should be simple enough. I was hoping to be able to get around this, but having a few specific parameters set to trigger the rule just wont work for our situation.

0 Likes
Message 15 of 18

WCrihfield
Mentor
Mentor

If you're just using the Geometry Change as the only trigger, the rule wouldn't necessarily have to be a  local one.  You can specify external rules within the Events Manager to be fired when local events happen too.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 16 of 18

jdbrown
Participant
Participant

Is it any more difficult to automate/script adding a trigger to run an external rule as opposed to a local rule?

0 Likes
Message 17 of 18

WCrihfield
Mentor
Mentor

Nope. Same process.  Open Event Triggers dialog box.  Upper left window lists local rules.  Lower left window lists external rules.  Drag the rule from one of those lists over under one of the events listed on the right.  Click OK. Done.

Pay attention to what tab within that dialog box you are in.  Anything you do within the "This Document" tab will only effect the open document.  Other tabs are pretty self explanatory.  If you use those other tabs, it will work for all documents of that type.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 18 of 18

WCrihfield
Mentor
Mentor

The dummy variables technique only works on local rules though, because of the way it recognizes those local Parameters and turns them blue whithin your code screen.  An external rule isn't linked to any specific CAD file, so it doesn't know when those parameters change.

All rules work with Events Manager though.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes