Change drawing section hatch layer according to material
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
I'd like to know if it is possible with iLogic or VBA code to automate the process of changing the layer for hatches on 2D drawing section views according to their material.
I found this forum discussion here but this talks about changing the view geometry lines and hidden lines according to material:
https://forums.autodesk.com/t5/inventor-programming-ilogic/assign-layers-to-materials/td-p/2871324
Whereas all I want to do is in effect select the hatch region and change it’s layer to the appropriate material layer.
We use many different materials and our company standard (in AutoCAD which I am trying to replicate as closely as possible in Inventor!) is to have a different hatch colour (layer) per material.
At the moment in Inventor I have the hatch styles set-up as I want in the Style and Standards Editor > Material Hatch Pattern Defaults tab so the correct hatch styles are used per material when taking section views. That’s working great!
I also have the layers set-up as I want. For example:
Layer Name / Colour:
'MDF' / Green
'Steel' / Blue
‘Solid Timber’ / Brown
My current process is to manually select each hatch region of a given material (E.G. all the hatch regions for MDF) and under the Annotate tab > Format > Layer drop down change the layer to the ‘MDF’ layer.
It would be a beautiful thing if this could be automated at the click of a button to do the above, either by:
- Selected view
- All views on a sheet
- Or all views on all sheets.
Even option 1. - just by one selected view at a time - would be amazing!
This would only apply to hatch regions that are ‘By Material’.
I.e. so if a hatch region in the Edit Hatch Pattern dialog (that you get when you double click / Right click a hatch region > Edit) has a check mark next to 'By Material' and the material is ‘MDF’, then the code will run to change the layer on which that hatch region resides to the MDF layer.
Hatch regions that are not 'By Material' would be ignored.
I guess the code would need to be edited to map the correct material to the correct layer.
If a layer does not exist for a material I think a pop up message would be best to say that that hatch region layer had not been changed and to prompt the user to make the appropriate layer (and necessary mapping addition to the code) and then run it again to mop-up that remaining hatch region and put it on the appropriate layer. Or I guess it could automatically create a new layer and have a pop up message alerting to the effect. Maybe that would be better actually!
Really hoping this might be possible!
Many thanks in advance and kind regards,
Oliver