I have a question on the layer functionality. I want to add a layer to a drawing that will show a hole plugged and hide the location dimension of the hole when the layer is turned on. Is this possible? And if it is possible, will this functionality transfer to a dwf when I publish the drawing in our company drawing library? I added a couple pics of what I'm trying to accomplish.
(1.JPG) shows the assembly with the hole open and a location dimension pulled.
(2.JPG) shows the assembly with the hole plugged and a location dimension hidden.
Solved! Go to Solution.
Solved by adam.nagy. Go to Solution.
Hi,
Creating a layer does not seem possible, since the Layers collection does not have an Add() function.
You can turn off a layer though:
Sub HideLayer() Dim doc As DrawingDocument Set doc = ThisApplication.ActiveDocument Dim l As Layer Set l = doc.StylesManager.Layers("MyLayer") l.Visible = False End Sub
Cheers,
Workaround exists: you may copy any existing layer and then change this copy properties to suit your needs.
"Moving sketch entities to a new layer API Sample" in the API help illustrates this approach.
cheers,
Good catch! 🙂
There is even a blog post on this: http://adndevblog.typepad.com/manufacturing/2012/05/changing-an-objects-layer-in-a-drawingdocument.h...
Thanks for your comment Adam, I currently have to have two layers one for the plug which is labled "L03" and the dimension location for the hole on a different layer called " Hide for L03". This works but it is confusing for the lady in our assembly department. I'm just trying to make it easier for them. The "L03" is a suffix that is added to our assembly number if the customer request the hole plugged. So when the assembly department opens the drawing it will explain in the notes on the drawing that the assembly employee needs to turn on this layer and hide this other layer. Simplifying this would save them possibly not getting the correct layer turned on and off in the DWF file.
Your code does not do this. I'm not very fluent in VB code. If the code could say:
If the Layer "L03" is turned on
Then turn off Layer "Hide for L03"
I'm sure that would not be a hard thing to code, but once it worked in Inventor, having it carry over to the DWF file probably is not possible. This is my thought.
I don't think DWF is capable of setting up layer relationships like that: if Layer A is on then Layer B should be off.
Inventor cannot do that either (as far as I know), but programmatically you can control which one is on or off.
@adam.nagy wrote:I don't think DWF is capable of setting up layer relationships like that: if Layer A is on then Layer B should be off.
Inventor cannot do that either (as far as I know), but programmatically you can control which one is on or off.
I think you are correct! Your answer is the best answer I have seen yet on getting closure on this question.
Here is a bit of iLogic code that will turn layers on or off based on a popup box answer. Simply set a trigger to "After Open Document" and will prompt the user for input whenever the drawing is opened. Doesn't worked on dwf's though as previously stated.
' Get the active document. Dim invDrawDoc As DrawingDocument invDrawDoc = ThisApplication.ActiveDocument question = MessageBox.Show("Is this a plugged hole?", "Plugged", MessageBoxButtons.YesNo, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1) 'set condition based on answer If question = vbYes Then ThisDrawing.Document.StylesManager.Layers("L03").Visible = True ThisDrawing.Document.StylesManager.Layers("Hide for L03").Visible = False Else If question = vbNo Then ThisDrawing.Document.StylesManager.Layers("L03").Visible = False ThisDrawing.Document.StylesManager.Layers("Hide for L03").Visible = True Else End If iLogicVb.UpdateWhenDone = True
snichols, thanks for the iLogic code. I will add it to my library. I have been dabbling with iLogic for a few weeks now and have found it quite usefull.