Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Hide Dimension when turning on a layer.

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
sgwilliams
401 Views, 8 Replies

Hide Dimension when turning on a layer.

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.
8 REPLIES 8
Message 2 of 9
adam.nagy
in reply to: sgwilliams

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
Message 3 of 9

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

Message 4 of 9

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
Message 5 of 9
sgwilliams
in reply to: adam.nagy

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.
Message 6 of 9
adam.nagy
in reply to: sgwilliams

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
Message 7 of 9
sgwilliams
in reply to: adam.nagy


@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.
Message 8 of 9
snichols
in reply to: sgwilliams

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

 

Message 9 of 9
sgwilliams
in reply to: snichols

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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report