ilogic rule to show named part sketches in an idw

ilogic rule to show named part sketches in an idw

drslayer35
Participant Participant
1,346 Views
3 Replies
Message 1 of 4

ilogic rule to show named part sketches in an idw

drslayer35
Participant
Participant

Greetings everyone,

 

I am looking for some code to include a specific named sketch from all parts in an assembly in a selected view in an idw.

I have the sketch named the same in every part but right now I have to go to the browser and "Get Model Sketches" and then go into every part of that assembly and "Include" the sketch I want to show.

Does anyone know of a way to make this easier?

 

Thanks,

Jeff

 

Product Design Suite Premium 2014

Windows 7 64

AMD FX8350  32GB

Dual AMD FirePro V4900

Thanks,
Jeff

Windows 7 64
Product Design Suite Premium 2014
AMD 8350 32 GB
Dual AMD FirePro V4900
0 Likes
Accepted solutions (1)
1,347 Views
3 Replies
Replies (3)
Message 2 of 4

Vladimir.Ananyev
Alumni
Alumni
Accepted solution

So the drawing view is referencing an assembly and the named sketch can be found in some parts in this assembly.

You need to iterate the occurrences collection.  In every occurrence you should try to find a PlanarSketch with the required name and then create the appropriate PlanarSketchProxy object.  You need to pass this PlanarSketchProxy object into the DrawingView.SetVisibility method.

 

The following VBA sample code illustrates this approach.

Sub Test_SetVisibility_Sketches_Assembly()
    'active drawing doc
    Dim oDrawDoc As DrawingDocument
    Set oDrawDoc = ThisApplication.ActiveDocument
    'active sheet
    Dim oSheet As Sheet
    Set oSheet = oDrawDoc.ActiveSheet
    'the 1st drawing view
    Dim oView As DrawingView
    Set oView = oSheet.DrawingViews.Item(1)
    
    'reference to the assembly document
    Dim oAsmDoc As AssemblyDocument
    Set oAsmDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument
    Dim oAsmDef As AssemblyComponentDefinition
    Set oAsmDef = oAsmDoc.ComponentDefinition
    
    'reference to some component (here it is the 1st)
    Dim oOcc As ComponentOccurrence
    Set oOcc = oAsmDef.Occurrences.Item(1)
    
    'reference to the part document
    Dim oDoc As PartDocument
    Set oDoc = oOcc.Definition.Document
    'part definition
    Dim oDef As PartComponentDefinition
    Set oDef = oDoc.ComponentDefinition
    'sketch in the part context
    Dim oSketch As PlanarSketch
    Set oSketch = oDef.Sketches.Item(2)
    
    'sketch in the assembly context - proxy object
    Dim oSketchProxy As PlanarSketchProxy
    Set oSketchProxy = Nothing
    Call oOcc.CreateGeometryProxy(oSketch, oSketchProxy)
    
    'make  PlanarSketchProxy visible
    Call oView.SetVisibility(oSketchProxy, True)
    
    Beep
End Sub

 Additional information you may find here

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

 

Proxy objects

http://modthemachine.typepad.com/my_weblog/2009/04/positioning-assembly-occurrences.html

http://adndevblog.typepad.com/manufacturing/2013/07/occurrences-contexts-definitions-proxies.html

 

cheers


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 4

drslayer35
Participant
Participant

Vladmir,

Thank you very much. This is what I was looking for. I am trying to modify your code to look into every part in the assembly and look for a specific named sketch.

I appreciate your time.

 

Jeff

Thanks,
Jeff

Windows 7 64
Product Design Suite Premium 2014
AMD 8350 32 GB
Dual AMD FirePro V4900
0 Likes
Message 4 of 4

Amit_11
Contributor
Contributor
Can we use this code for the views coming out of single part instead of Assembly?

Thanks in Advance,

Amit Bhatteja
0 Likes