Showing posts with label form. Show all posts
Showing posts with label form. Show all posts

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

Thursday, 3 July 2014

iLogic Rules

I have just spent the last couple of days playing with iLogic. I am doing a tank template that I will present in the next couple of posts and it's all been done with iLogic and iFeatures.
Meanwhile I decided to present you a couple of iLogic routines and programs I am using. I have collected a couple and hope you will find them useful.
I don't have any programming experience, so all codes have been downloaded off the internet, tried and tested.
The main ones that I use are Export to PDF, DWF, and DXF. The reason I use ilogic is to automatically add revision to the filename. You can also chose export folder so one more thing out of the way.
I also use iLogic to force update iProperties of the drawing from the model. I have a code to set the scale of the model in the drawing and one to add virtual parts to the assembly from a text document. (Curtis Waguespack's code). He also gives a code to force turning all features off down level on all components (huge time saver)
Create a folder for your iLogic codes, recommend to use a map network drive location so they are available for all users in your company.
Open a file and go to Manage \ iLogic \ iLogic Browser , switch to External Rules tab. Right click and add external rule. Add your rules, in my case UpdateProps (force update of properties), SavePDF, SaveDXF, SaveDWF.


Switch to Global Forms and Add Form. If you have a common Design Data folder on the network then this Form will be available to all users ;) . Drag your rules on the right and change the name of the buttons and of the form if needed.



I know you can add buttons on the ribbon and quick access bar but you need to configure it with every new Inventor release so I prefer to have a global form instead.
At times I need to do a batch of files so I use Code Injector, a small utility that will do that for you. We once had around 900 drawings to export to dxf and pdf so we just left the injector run overnight. Here is the post and description. http://beinginventive.typepad.com/being-inventive/2012/02/injecting-ilogic-code-and-ilogic-event-triggers-automatically.html




Virtual Components
Issue:
You have a number of standard Virtual parts that you find yourself adding over and over. You'd like to have the ability to add them based on a predefined list.
Check his blog here for the code.
I use this to add various stuff like: oil for gearboxes and hydraulic units, paint and primer, chemical for anchor bolts, grout, etc.

Work Features
Issue:
You have other members of your design team that do not remember to turn off work features at the part level or sub-assembly level when they are done working with those files. As a result file previews and view representations get messed up. You'd like to have a quick way to toggle all of the work features off. Can this be done with iLogic?
 Check his blog here for the code.

Update copied properties.
Issue:
You have a lot of drawings that need update copied iproperties of the model (updates copied iproperties of the model in the drawing).
Solution:
Use the code to force the drawing to update copied properties from the model. Can be used with Code Injector to do a batch of drawings at a time.
File to be used: UpdateProps.iLogicVb

Save PDF
Issue:
You have to export one or many drawings at a time to pdf.
Solution:
Use the code to export current drawing to pdf. It creates (if didn't exist) a folder called DXF on same path as drawing (needs saving first) in which a pdfwith the filename being "Drawing_filename + Drawing_description + Revision". Can be used with Code Injector to do a batch of drawings at a time.
Make SURE that the drawing is saved otherwise the path of the folder and pdf will be on root drive.

Save DXF

Issue:
You have to export one or many drawings at a time to dxf.
Solution:
Use the code to export current drawing to dxf. It creates (if didn't exist) a folder called DXF on same path as drawing (needs saving first) in which a dxf with the filename being "Drawing_filename + Drawing_description + Revision". Can be used with Code Injector to do a batch of drawings at a time.
Make SURE that the drawing is saved otherwise the path of the folder and dxf will be on root drive.


Scale of first view in titleblock

In order to have the scale show up and update automatically in the titleblock, do the following.
Edit your title block definition and add a Text item with the type Prompted Entry
This text should contain <Scale>

After you add this, Inventor will prompt you for a Scale value whenever you add the title block to a sheet.
The same happens when you add a new sheet with the title block to the drawing or when you start a new drawing using a template where you have applied this solution.
When it prompts you, just leave the value blank

Then add the rule in text bellow to the drawing
File to be used: Prompted_Scale.txt
Add the rule to the trigger “Before Save Document”

After that, on every sheet in the drawing, you will get the scale value from the first view on that sheet in the title block when you save the file.


What rules do you use? Please let me kow what's your favorite?
ADS