Thursday, 30 April 2015

Edit iProperties with global forms

I’m fed up with this problem so I’ve decided to solve it and since the result came out pretty nice I will share it with you and will try and cover but fusion fittings next time.
PROBLEM1:
                 - You have a drawing with multiple LOD’s (Level of Detail) and you want to change iproperties of the model like for example if you need to change the description of the model. So you right click on a view it could even be the main view, main LOD and select open. You try and change some iproperties and Inventor throws a window telling you that you that a different LOD is being edited and before you close that you can’t save the assembly!
WHAT…. I am just trying to change iproperties, what’s that got to do with LOD? See my post on Inventor forum here : http://forums.autodesk.com/t5/inventor-general-discussion/quot-the-assembly-must-be-saved-before-performing-the-bill-of/m-p/5601004#M543896
PROBLEM 2:
- You need to have multi-line iPropertie texts in the title block and you need to control what goes on each line, control the end of line.
PROBLEM 3:
                 - You got bored opening models just to can alter properties, especially on large assemblies.
PROBLEM 4:
                - You don’t want to hunt for different ipropeties on different tabs, rather lazy want them all in one place for fast editing
SOLUTION:
                Create a form that will edit the properties without opening the assembly, where you add all your needed info in one page with multi-line iProperties on it.




                First you need to setup the folder for your iLogic codes so go to Tools / Options / iLogic Configuration and add a folder in your “External Rule Directories”. This way you can use external rules and keep your drawing template clean and small.
                If you’re working in a shared environment you might want to copy all your design data on a shared network drive because any external forms you add will be available to all your colleagues this way. The files will be located in ..Design Data / iLogic / UI.
                Open a drawing (could be your template.idw) and click on Manage/iLogic/iLogic Browser and head over to global forms tab. Right click create a new form, give it a proper name (Label field) and make sure Modal is set to false (so you can do other stuff in Inventor while this is open on top).

                 Click ok for now and let’s add a couple of empty iLogic rules that will appear as buttons on our form.
                Head over to the “External Rules” tab on the iLogic browser pane and create new external rules by right clicking. This is what I’ve added:
·         “iPropsFromModel” – to copy existing properties from the model.
·         “iPropsToModel” – in case you want to update the model with the drawing iproperties.
·         “DrawingCheckIn” – if you use vault you can check the drawing and model back to vault.
·         “Drw_Create_Parameters” – this will create the multi-line properties if they don’t exist in the drawing
·         “Drw_Update_iProps” – to force update the iproperties with our multi-line parameters
·         “Save_PDF_DWF” – to automate creation of PDF’s and DWF’s

                In order to add things to your form you need to drag them from the left pane, “Parameters”, “Rules”, “iProperties” or “Tollbox” into the top right pane in the order you want them to show up. Here’s the sequence from my form:


                Resizing the form while editing it is not persistent, so you need to run the form and choose "resize Controlls" while right cliking on the form, check my previous blog here:

                All iProperties are multi-line texts but the iproperties window will only show you the last line of text and will allow you to control the end of line just for the “Comments” field. To test it out type your custom text inside “Comments” and call it in “Description” by adding this formula =<Comments> and you will see the title block showing your line-by-line formatted text.
                You can add Description to your form but it doesn’t display as multi-line and for that you need to create custom parameters, in my case called the same for simplicity: Description and Project.
                Now you can add the above parameters to your form and change “Edit Control Type” to “Multi-line Text Box”. Make sure you resize your form so you can better see all the lines, I keep mine to 3 visible lines but as soon as you pass that the scrollable arrows become active on the right.
               

                I could have included some of these codes inside the drawing template but I want to keep it as clean as possible, minimizing crashes and problems when upgrading to new releases of Inventor.
                The other reason I have separate button (code) for creating Description and Project parameters is so that you can edit old drawings for which you would have to recreate the ilogic rule. Remember that those drawings don’t have Description and Project as parameters so you either add them manually or run this code. You can easily copy an external rule into the document or you could have used code injector to push this code into a batch of drawings. Here’s the link for codeinjector.
                I think it’s not worth the hassle; it’s just one click away to create the parameters in the form so I suggest you add this button to your form even though you might not use it all the times.
                Because I want this form to show up automatically with each new drawing I need to add a small ilogic code inside the drawing template and trigger it before save. The code has a nice trick to only pop-up the form at first time you save the drawing. I don’t want to see it every time I save a drawing especially on large assemblies.



                The trick was to check if the drawing was saved before, having a path on disk and for that we’ll use “IsNullOrWhiteSpace” to verify it. If it doesn’t have a path then just before saving the drawing fire up the form. The drawing still saves but the form shows up as well.
                  Here isthe drawing (AIP 2015), the rules and the form included (you need to copy it over to global forms).
                This way I can edit the model iProperties without needing to open the model which throws out that ugly error about different LOD being edited.


Later,
ADS