Include/Exclude or Visibility on/off : Model sketches in drawing views.

Include/Exclude or Visibility on/off : Model sketches in drawing views.

CCarreiras
Mentor Mentor
815 Views
3 Replies
Message 1 of 4

Include/Exclude or Visibility on/off : Model sketches in drawing views.

CCarreiras
Mentor
Mentor

Hi!

 

In a drawing, i had include the model skeches.

 

I have several sketches, and deppending the situation, i need to include or exclude one of the sketches.

Since i can't use the sketch layer visibility on/off, because it will show/ide all the sketches, so the question is.

 

There's some iLogic code to include/exclude sketches in the drawing views? Or turning the visibility on/off?

 

 

CCarreiras

EESignature

0 Likes
816 Views
3 Replies
Replies (3)
Message 2 of 4

Balaji_Ram
Alumni
Alumni

Hi Carlos,

 

The VB.Net code from this blog post should help implement a similar sketch retrieval using iLogic.

 

http://adndevblog.typepad.com/manufacturing/2012/06/include-sketches-from-sub-assemblies-in-a-drawin...

 

Regards,

Balaji



Balaji
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 4

CCarreiras
Mentor
Mentor

Hi!

 

I don't need to have in the code the possibility to include  the sketches when i create a view.

 

I have the view already placed in the drawing, and i have all the part sketches already included  in the view.

Example:

Let's say the view has two included sketchs; A and B.

 

Now i want to make an if then else rule to do this:

 

If parameter=1 then

 

show included sketch A

Hide included sketch B

 

elseif parameter=2

 

hide included sketch A

SHow included sketch B

 

end if

CCarreiras

EESignature

0 Likes
Message 4 of 4

Balaji_Ram
Alumni
Alumni

Hi Carlos,

 

The code from that blog post can also be used to change the visibility of sketches already included in the drawing view.

 

Here is an iLogic code example and a recording :

 

Dim oDrawingDoc As DrawingDocument
oDrawingDoc = ThisDoc.Document

oView = oDrawingDoc.ActiveSheet.DrawingViews(1)

Dim oDoc As Document
oDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument
If oDoc.DocumentType <> kAssemblyDocumentObject Then
    MsgBox ("View's Referenced doc needs to be an assembly")
    Return
End If

Dim oAssy As AssemblyDocument
oAssy = oView.ReferencedDocumentDescriptor.ReferencedDocument

'    Dim oSubOcc As ComponentOccurrence
'    For Each oSubOcc In oAssy.ComponentDefinition.Occurrences
'
'        If oSubOcc.DefinitionDocumentType = kAssemblyDocumentObject Then
'
'            Dim oSubAssyDef As AssemblyComponentDefinition
'            Set oSubAssyDef = oSubOcc.Definition
'
'            Dim oSketch As PlanarSketch
'            Debug.Print (oSubAssyDef.Sketches.Count)
'            For Each oSketch In oSubAssyDef.Sketches
'
'                Dim oSketchProxy As PlanarSketchProxy
'                Call oSubOcc.CreateGeometryProxy(oSketch, oSketchProxy)
'
'                Call oView.SetVisibility(oSketchProxy, True)
'            Next
'        End If
'    Next

Dim oAssyDef As AssemblyComponentDefinition
oAssyDef = oAssy.ComponentDefinition

Dim oSketch As PlanarSketch
For Each oSketch In oAssyDef.Sketches
	Call oView.SetVisibility(oSketch, False)
	
	If oSketch.Name =  "HorizontalSlot" Then
		If SlotPosition = "Horizontal" Then
			Call oView.SetVisibility(oSketch, True)
		End If
	End If
	
	If oSketch.Name =  "VerticalSlot" Then
		If SlotPosition = "Vertical" Then
			Call oView.SetVisibility(oSketch, True)
		End If
	End If
Next

http://autode.sk/1OyUD2H

 

Regards,

Balaji



Balaji
Developer Technical Services
Autodesk Developer Network

0 Likes