Hey chaps.
I'va managed to cobble this code together to turn some sketch visibilities on and off. However, what I'd really like to do is have a single sketch containg some blocks, and turn the visibility of the blocks on and off...
I'm struggling to work out how to call the blocks - can YOU help!
Paul
'Iterate through the sketches collection 'Turn the edging indicators On And Off For Each oSketch In oDoc.ComponentDefinition.Sketches Select Case oSketch.Name Case "Front Edged" If E01 = True Then oSketch.Visible = True Else oSketch.Visible = False End If Case "Top Edged" If E02 = True Then oSketch.Visible = True Else oSketch.Visible = False End If Case "Back Edged" If E03 = True Then oSketch.Visible = True Else oSketch.Visible = False End If Case "Base Edged" If E04 = True Then oSketch.Visible = True Else oSketch.Visible = False End If End Select Next
Autodesk Industry Marketing Manager UK D&M
Opinions are my own and may not reflect those of my company.
Linkedin | Twitter | Instagram | Facebook | Pinterest
Solved! Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
Hi Paul,
Here's a quick example:
Dim oSketches As PlanarSketches
oSketches = ThisApplication.ActiveDocument.ComponentDefinition.Sketches
Dim oSketch As PlanarSketch
oSketch = oSketches.Item("Sketch2")
Dim MyArrayList As New ArrayList
MyArrayList.add("Back Edged")
MyArrayList.add("Base Edged")
MyArrayList.add("Front Edged")
MyArrayList.add("Top Edged")
MyArrayList.add("Turn ON all blocks")
MyArrayList.add("Turn OFF all blocks")
myBlock = InputListBox("Select a block to turn ON", _
MyArrayList, MyArrayList.item(0),"iLogic", "Sketch Block Names")
Dim oSketchBlock As SketchBlock
For Each oSketchBlock In oSketch.SketchBlocks
'get position of colon, example: MyBlock:2 returns 8
iPos = InStr(oSketchBlock.Name, ":")
'get block name, example: MyBlock:2 returns MyBlock
sBlockName = Left(oSketchBlock.Name, iPos -1)
If myBlock = "Turn ON all blocks" Then
oSketchBlock.Visible = True
Else If myBlock = "Turn OFF all blocks" Then
oSketchBlock.Visible = False
Else If myBlock = sBlockName Then
oSketchBlock.Visible = True
End If
'if any sketch block is visible make the sketch visible
If oSketchBlock.Visible = true Then oSketch.Visible = True
Next
I hope this helps,
Curtis
http://inventortrenches.blogspot.com
Hi Curtis;
Thanks for the posting.
I am using a test version of the coding to make vsible the blocks in my sketch (Sketch12) visible. There are a few blocks. However, while the Sketch12 is not visible, the blocks in the sketch don't turn on (not visible). Could you help me, please.
Dim oSketches As PlanarSketches
oSketches = ThisApplication.ActiveDocument.ComponentDefinition.Sketches
Dim oSketch As PlanarSketch
oSketch = oSketches.Item("Sketch12")
Dim oSketchBlock As SketchBlock
For Each oSketchBlock In oSketch.SketchBlocks
'get position of colon, example: MyBlock:2 returns 8
iPos = InStr(oSketchBlock.Name, ":")
'get block name, example: MyBlock:2 returns MyBlock
sBlockName = Left(oSketchBlock.Name, iPos-1)
oSketchBlock.Visible = True
' If oSketchBlock.Visible = True Then oSketch.Visible = True
Next
Thanks.