Hide Dimension when turning on a layer.

Hide Dimension when turning on a layer.

sgwilliams
Collaborator Collaborator
734 Views
8 Replies
Message 1 of 9

Hide Dimension when turning on a layer.

sgwilliams
Collaborator
Collaborator

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.

Work Station : Custom built, Liquid Cooled, Asus Pro WS X570-ACE Motherboard; AMD Ryzen 9 3900X 3.8 GHz 12-Core Processor; ASUS TUF Gaming NVIDIA GeForce RTX 3060 V2 OC Edition Video Card; 32 GB CORSAIR Dominator Platinum DDR4-2132 Memory ; Samsung 850 EVO 1TB SSD Drive.
0 Likes
Accepted solutions (1)
735 Views
8 Replies
Replies (8)
Message 2 of 9

adam.nagy
Autodesk Support
Autodesk Support

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,



Adam Nagy
Autodesk Platform Services
0 Likes
Message 3 of 9

Vladimir.Ananyev
Alumni
Alumni

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,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 4 of 9

adam.nagy
Autodesk Support
Autodesk Support

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...



Adam Nagy
Autodesk Platform Services
0 Likes
Message 5 of 9

sgwilliams
Collaborator
Collaborator

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.

Work Station : Custom built, Liquid Cooled, Asus Pro WS X570-ACE Motherboard; AMD Ryzen 9 3900X 3.8 GHz 12-Core Processor; ASUS TUF Gaming NVIDIA GeForce RTX 3060 V2 OC Edition Video Card; 32 GB CORSAIR Dominator Platinum DDR4-2132 Memory ; Samsung 850 EVO 1TB SSD Drive.
0 Likes
Message 6 of 9

adam.nagy
Autodesk Support
Autodesk Support
Accepted solution

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
Autodesk Platform Services
0 Likes
Message 7 of 9

sgwilliams
Collaborator
Collaborator

@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. 

Work Station : Custom built, Liquid Cooled, Asus Pro WS X570-ACE Motherboard; AMD Ryzen 9 3900X 3.8 GHz 12-Core Processor; ASUS TUF Gaming NVIDIA GeForce RTX 3060 V2 OC Edition Video Card; 32 GB CORSAIR Dominator Platinum DDR4-2132 Memory ; Samsung 850 EVO 1TB SSD Drive.
0 Likes
Message 8 of 9

snichols
Advocate
Advocate

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

 

0 Likes
Message 9 of 9

sgwilliams
Collaborator
Collaborator

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.

Work Station : Custom built, Liquid Cooled, Asus Pro WS X570-ACE Motherboard; AMD Ryzen 9 3900X 3.8 GHz 12-Core Processor; ASUS TUF Gaming NVIDIA GeForce RTX 3060 V2 OC Edition Video Card; 32 GB CORSAIR Dominator Platinum DDR4-2132 Memory ; Samsung 850 EVO 1TB SSD Drive.
0 Likes