Get model sketch in drawing view

Get model sketch in drawing view

Rene-J
Collaborator Collaborator
369 Views
5 Replies
Message 1 of 6

Get model sketch in drawing view

Rene-J
Collaborator
Collaborator
Hi
Is it possible to set the (get model sketch) off a part

I have a sample it show how to set the sketch visibility.
But it only working if the (get model sketch) is set
I am using INV 2008.

Private Sub SketchVisibility()

' Get the active drawing document
Dim oDrawing As DrawingDocument
Set oDrawing = ThisApplication.ActiveDocument

' Get the referenced part document
Dim oPart As PartDocument
Set oPart = oDrawing.ReferencedFiles.Item(1)

Dim oDef As PartComponentDefinition
Set oDef = oPart.ComponentDefinition


' Get the first sketch in the part
Dim oSketch As Sketch
Set oSketch = oDef.Sketches.Item(1)

' Make the sketch visible in drawing


Call oDrawing.ActiveSheet.DrawingViews(1).SetVisibility(oSketch, True)

End Sub

René J
0 Likes
370 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
This macro seems to run fine on my machine (Inventor 2008) and makes the
sketch visible. Are you sure the sketch plane is parallel to the drawing
view?

Sanjay-

"René J <>" <=?UTF-8?Q?Ren=C3=A9_J_<>?=> wrote in message
news:5644674@discussion.autodesk.com...
Hi
Is it possible to set the (get model sketch) off a part

I have a sample it show how to set the sketch visibility.
But it only working if the (get model sketch) is set
I am using INV 2008.

Private Sub SketchVisibility()

' Get the active drawing document
Dim oDrawing As DrawingDocument
Set oDrawing = ThisApplication.ActiveDocument

' Get the referenced part document
Dim oPart As PartDocument
Set oPart = oDrawing.ReferencedFiles.Item(1)

Dim oDef As PartComponentDefinition
Set oDef = oPart.ComponentDefinition


' Get the first sketch in the part
Dim oSketch As Sketch
Set oSketch = oDef.Sketches.Item(1)

' Make the sketch visible in drawing


Call oDrawing.ActiveSheet.DrawingViews(1).SetVisibility(oSketch, True)

End Sub

René J
0 Likes
Message 3 of 6

Rene-J
Collaborator
Collaborator
I think you have misunderstand my question
I need to set or select the (Get model sketches).
before I can run my macro.

René J
0 Likes
Message 4 of 6

Anonymous
Not applicable
Well, I didn't need to set the 'Get model sketches' before running the macro
(and it still worked fine). Why do you need to set that?

Sanjay-

"René J <>" <=?UTF-8?Q?Ren=C3=A9_J_<>?=> wrote in message
news:5645341@discussion.autodesk.com...
I think you have misunderstand my question
I need to set or select the (Get model sketches).
before I can run my macro.

René J
0 Likes
Message 5 of 6

Rene-J
Collaborator
Collaborator
Sorry I have tested the macro and noting
happened, but now it work fine. I think it ways
the wrong sketch I was trying to set visibility.

Do you know how to set a sketch visibility in subassembly/subparts?
René J
0 Likes
Message 6 of 6

Anonymous
Not applicable
You need to get the corresponding proxy object (PlanarSketchProxy) in the
context of the top level assembly and use that as input to the SetVisibility
method.

Sanjay-

"René J <>" <=?UTF-8?Q?Ren=C3=A9_J_<>?=> wrote in message
news:5645375@discussion.autodesk.com...
Sorry I have tested the macro and noting
happened, but now it work fine. I think it ways
the wrong sketch I was trying to set visibility.

Do you know how to set a sketch visibility in subassembly/subparts?
René J
0 Likes