Selecting Bodies in Drawing with vba

Hello

 

I'm still on my assembly setup, and I'm almost getting there. I'm missing a little element.

To finish my project, I open a drawing, and I ask him to position me with views of several rooms. So far you're fine, except that I come across a coin with 2 bodies, and I want to have a view of my first body unfolded, and a view of my second body.

Here is an example of my procedure for recovering views.

Set swModel = swApp.OpenDoc6("Z:\MACHINE\CONFO\0 confo ORIGINE 3D\Sheet metal confo ORIGINE.slddrw", 3, 0, "", longstatus, longwarnings)    
    Set Part = swApp.ActiveDoc
    
    Set myModelView = Part.CreateDrawViewFromModelView2("Z:\MACHINE\CONFO\" & Range("d1"). Value2 & " base.sldprt", "*Top", 0.33, 0.68, 0)
    boolstatus = Part.ChangeRefConfigurationOfFlatPatternView("Z:\MACHINE\CONFO\" & Range("d1"). Value2 & " base.sldprt", "Default")

    Set myModelView = Part.CreateDrawViewFromModelView2("Z:\MACHINE\CONFO\" & Range("d1"). Value2 & " wing.sldprt", "*Face", 0.33, 0.43, 0)
    boolstatus = Part.ChangeRefConfigurationOfFlatPatternView("Z:\MACHINE\CONFO\" & Range("d1"). Value2 & " wing.sldprt", "Default")

    Set myModelView = Part.CreateDrawViewFromModelView2("Z:\MACHINE\CONFO\" & Range("d1"). Value2 & " corridor.sldprt", "*Face", 0.33, 0.18, 0)
    boolstatus = Part.ChangeRefConfigurationOfFlatPatternView("Z:\MACHINE\CONFO\" & Range("d1"). Value2 & "corridor.sldprt", "Default")

    Set myModelView = Part.CreateDrawViewFromModelView2("Z:\MACHINE\CONFO\" & Range("d1"). Value2 & " corridor.sldprt", "*Face", 0.95, 0.68, 0)
    'boolstatus = Part.ChangeRefConfigurationOfFlatPatternView("Z:\MACHINE\CONFO\" & Range("d1"). Value2 & "corridor.sldprt", "Default")

    Set myModelView = Part.CreateDrawViewFromModelView2("Z:\MACHINE\CONFO\" & Range("d1"). Value2 & " base.sldprt reinforcement", "Unfolded state", 0.95, 0.43, 0)
    boolstatus = Part.ChangeRefConfigurationOfFlatPatternView("Z:\MACHINE\CONFO\" & Range("d1"). Value2 & "base.sldprt reinforcement", "Default")

The room concerned is the one with corridor.sldprt.

 

Kind regards.

Hello To hide a body you can use the display3 method of the ibody2 interface. You must first list the bodies with enumbodies2
Hello To hide a body you can use the display3 method of the ibody2 interface. You must first list the bodies with enumbodies2

Thanks for the info, but how can I integrate these instructions?

 

Kind regards.

I managed to open the room with a precise config, and add my view

boolstatus = Part.Extension.SelectByID2("Z:\MACHINE\CONFO\" & Range("d1"). Value2 & " corridor.sldprt", "CONFIGURATIONS", 0, 0, 0, False, 0, Nothing, 0)
    boolstatus = Part.ShowConfiguration2("corps_couloir")
    Set myModelView = Part.CreateDrawViewFromModelView2("Z:\MACHINE\CONFO\" & Range("d1"). Value2 & "corridor.sldprt", "Unfolded state", 0.45, 0.18, 0)
    boolstatus = Part.ChangeRefConfigurationOfFlatPatternView("Z:\MACHINE\CONFO\" & Range("d1"). Value2 & " corridor.sldprt", "corps_couloir")

1 Like