Ilogic rule question about export to dwg

Ilogic rule question about export to dwg

EMVC
Advocate Advocate
1,781 Views
29 Replies
Message 1 of 30

Ilogic rule question about export to dwg

EMVC
Advocate
Advocate

Hello

 

Is it possible to make a rule to export all parts of this assembley idw to single dwg sheets, with filename from part table (same as balloon) on each dwg + thinkness +qty from parttable

 

we must make plasma files in dwg from each part, and it is a lot of work during a year

qty is important also thinkness, but idont know how to get that info in part table, maybe use length ?

a stair will be made by several parts of thinkness

Steps/Landing (sheet metal) should also be unfolded in dwg

 

Part table is not complete here, this is just an example,

 

Skjermbilde.JPG

0 Likes
1,782 Views
29 Replies
Replies (29)
Message 2 of 30

EMVC
Advocate
Advocate

I also forget files in a folder in same as idw file

And i need cut lines and scribe lines thats also tricky i think

0 Likes
Message 3 of 30

EMVC
Advocate
Advocate

Hello

 

here i post page 2 , is the a way to export this parts in a single idw with multiple parts into separte dwg with file name and pcs if it is possible, sheet metal as in steps i can unfold and put on idw sheet, i can also make cut and scribe lines in autocad after convert, in this way i also save time

 

 

Skjermbilde.JPG

0 Likes
Message 4 of 30

chandra.shekar.g
Autodesk Support
Autodesk Support

@EMVC,

 

Is it possible to share non confidential files which contains expected result and input files?

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 5 of 30

EMVC
Advocate
Advocate

Hello

 

here it is, Thank you for ask, scribe lines i think i must make in Autocad after export,

0 Likes
Message 6 of 30

EMVC
Advocate
Advocate

Hello

 

i forgot steps and landing, use this instead

0 Likes
Message 7 of 30

chandra.shekar.g
Autodesk Support
Autodesk Support
0 Likes
Message 8 of 30

EMVC
Advocate
Advocate

Hello

 

I think the first link is what i am looking for, can it export to dwg instead

We must draw everything in sheet metal as i understand,  now we have both sheet metal and standart.ipt

 

I can not get it to run it makes folder but no files

 

0 Likes
Message 9 of 30

chandra.shekar.g
Autodesk Support
Autodesk Support

@EMVC,

 

Try below modified VBA code to export into dxf.

Sub Export_Sheetmetal()
    'define the active document as an assembly file
    Dim oAsmDoc As AssemblyDocument
    Set oAsmDoc = ThisApplication.ActiveDocument
    
    Dim oAsmName As String
    oAsmName = Left(oAsmDoc.DisplayName, Len(oAsmDoc.DisplayName) - 4)
    
    
    
    'check that the active document is an assembly file
    If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then
        
        MsgBox ("Please run this rule from the assembly file.")
        Exit Sub
        
    End If
    
    'get user input
    Result = MsgBox("This will create a DXF file for all of the asembly components that are sheet metal." _
    & vbLf & "This rule expects that the part file is saved." _
    & vbLf & " " _
    & vbLf & "Are you sure you want to create DXF for all of the assembly components?" _
    & vbLf & "This could take a while.", vbYesNo, "iLogic  - Batch Output DXFs ")
    
    If Result = vbNo Then
    
        Exit Sub
        
    End If
    
    Dim oPath As String
    Dim iSplit As Integer
    
    iSplit = InStrRev(oAsmDoc.FullDocumentName, "\")
    
    oPath = Left(oAsmDoc.FullDocumentName, iSplit - 1)
     
    Dim oDataMedium As DataMedium
    Set oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
    
    Dim oContext As TranslationContext
    Set oContext = ThisApplication.TransientObjects.CreateTranslationContext
    
    oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
    
    Dim oOptions As NameValueMap
    Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap
    
    'get DXF target folder path
    Dim oFolder As String
    oFolder = oPath & "\" & oAsmName & " DXF Files"
    
    'Check for the DXF folder and create it if it does not exist
    If Len(Dir(oFolder, vbDirectory)) = 0 Then
        MkDir oFolder
    End If
    '- - - - - - - - - - - - -
    
    '- - - - - - - - - - - - -Component  - - - - - - - - - - - -
    'look at the files referenced by the assembly
    Dim oRefDocs As DocumentsEnumerator
    
    Set oRefDocs = oAsmDoc.AllReferencedDocuments
    
    Dim oRefDoc As Document
    Dim iptPathName As String
    
    'work the the drawing files for the referenced models
    'this expects that the model has been saved
    For Each oRefDoc In oRefDocs
    
        If oRefDoc.DocumentSubType.DocumentSubTypeID = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
    
            Dim oDrawDoc As PartDocument
            
            Set oDrawDoc = ThisApplication.Documents.Open(oRefDoc.FullDocumentName, True)
            
            oFileName = Left(oRefDoc.DisplayName, Len(oRefDoc.DisplayName) - 4)
            
            'Set the DXF target file name
            oDataMedium.FileName = oFolder & "\" & oFileName & ".dxf"
        
            Dim oCompDef As SheetMetalComponentDefinition
        
            Set oCompDef = oDrawDoc.ComponentDefinition
            
            If oCompDef.HasFlatPattern = False Then
            
                oCompDef.Unfold
                
            Else
            
                oCompDef.FlatPattern.Edit
                
            End If
    
            Dim sOut As String
        
            sOut = "FLAT PATTERN DXF?AcadVersion=2004&OuterProfileLayer=IV_OUTER_PROFILE"
    
            
            Call oCompDef.DataIO.WriteDataToFile(sOut, oFolder & "\" & oFileName & ".dxf")
        
            'just for check its works coretcly
            'i=MessageBox.Show(oDataMedium.FileName, "Title",MessageBoxButtons.OKCancel)
            
            'MessageBox.Show(i,"title",MessageBoxButtons.OK)
        
            'If i=2 Then
        
                'Exit Sub
        
            'End If
    
            oCompDef.FlatPattern.ExitEdit
            
            oDrawDoc.Close
            
        End If
    Next
End Sub

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 10 of 30

EMVC
Advocate
Advocate

Hello

 

This worked, is it possible to remove bend lines and convert to dwg instread of dxf

in pcs also something it possible to implent

0 Likes
Message 11 of 30

EMVC
Advocate
Advocate

Hello

 

i covert a standard .ipt to sheet metal , it seems like the part will come out mirror se pictures, Mirror 1.JPGMirror 2.JPG

0 Likes
Message 12 of 30

EMVC
Advocate
Advocate

Hello

 

I modified it a littlebit so i get ctlines and scribe lines se red line, but how to add color to the layers and i want to remove tangent layer

 

Sub Export_Sheetmetal()
'define the active document as an assembly file
Dim oAsmDoc As AssemblyDocument
Set oAsmDoc = ThisApplication.ActiveDocument

Dim oAsmName As String
oAsmName = Left(oAsmDoc.DisplayName, Len(oAsmDoc.DisplayName) - 4)



'check that the active document is an assembly file
If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then

MsgBox ("Please run this rule from the assembly file.")
Exit Sub

End If

'get user input
Result = MsgBox("This will create a DXF file for all of the asembly components that are sheet metal." _
& vbLf & "This rule expects that the part file is saved." _
& vbLf & " " _
& vbLf & "Are you sure you want to create DXF for all of the assembly components?" _
& vbLf & "This could take a while.", vbYesNo, "iLogic - Batch Output DXFs ")

If Result = vbNo Then

Exit Sub

End If

Dim oPath As String
Dim iSplit As Integer

iSplit = InStrRev(oAsmDoc.FullDocumentName, "\")

oPath = Left(oAsmDoc.FullDocumentName, iSplit - 1)

Dim oDataMedium As DataMedium
Set oDataMedium = ThisApplication.TransientObjects.CreateDataMedium

Dim oContext As TranslationContext
Set oContext = ThisApplication.TransientObjects.CreateTranslationContext

oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism

Dim oOptions As NameValueMap
Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap

'get DXF target folder path
Dim oFolder As String
oFolder = oPath & "\" & oAsmName & " DXF Files"

'Check for the DXF folder and create it if it does not exist
If Len(Dir(oFolder, vbDirectory)) = 0 Then
MkDir oFolder
End If
'- - - - - - - - - - - - -

'- - - - - - - - - - - - -Component - - - - - - - - - - - -
'look at the files referenced by the assembly
Dim oRefDocs As DocumentsEnumerator

Set oRefDocs = oAsmDoc.AllReferencedDocuments

Dim oRefDoc As Document
Dim iptPathName As String

'work the the drawing files for the referenced models
'this expects that the model has been saved
For Each oRefDoc In oRefDocs

If oRefDoc.DocumentSubType.DocumentSubTypeID = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then

Dim oDrawDoc As PartDocument

Set oDrawDoc = ThisApplication.Documents.Open(oRefDoc.FullDocumentName, True)

oFileName = Left(oRefDoc.DisplayName, Len(oRefDoc.DisplayName) - 4)

'Set the DXF target file name
oDataMedium.FileName = oFolder & "\" & oFileName & ".dxf"

Dim oCompDef As SheetMetalComponentDefinition

Set oCompDef = oDrawDoc.ComponentDefinition

If oCompDef.HasFlatPattern = False Then

oCompDef.Unfold

Else

oCompDef.FlatPattern.Edit

End If

Dim sOut As String

sOut = "FLAT PATTERN DXF?AcadVersion=2004&OuterProfileLayer=Cut&featureprofilesdownLayer=Scribe&interiorprofilesLayer=Cut"
sOut = "FLAT PATTERN DXF?AcadVersion=2004&tangentLayer=False"

Call oCompDef.DataIO.WriteDataToFile(sOut, oFolder & "\" & oFileName & ".dxf")

'just for check its works coretcly
'i=MessageBox.Show(oDataMedium.FileName, "Title",MessageBoxButtons.OKCancel)

'MessageBox.Show(i,"title",MessageBoxButtons.OK)

'If i=2 Then

'Exit Sub

'End If

oCompDef.FlatPattern.ExitEdit

oDrawDoc.Close

End If
Next
End Sub

 

0 Likes
Message 13 of 30

EMVC
Advocate
Advocate

Hello

 

i add this when i got color, but i still miss to remove bend lines i also see that i must make arc center invisible

 

and make part not mirror as picture above

 

sOut = "FLAT PATTERN DXF?AcadVersion=2004&OuterProfileLayer=Cut&OuterProfileLayerColor=0;255;0&featureprofilesdownLayer=Scribe&featureprofilesdownLayerColor=255;0;255&interiorprofilesLayer=Cut"

 

 

0 Likes
Message 14 of 30

EMVC
Advocate
Advocate

Hello

 

I have tried to modify it a little bit, it works but it is not perfect modify se in red

 

I hope now to implent so part dont comes out as mirror se picture above

 

I hope also to get part will come in diffrent folder after thickness if it is possible also pcs so i dont have to do that manuell

 

 

 

Sub Export_Plasma()
'define the active document as an assembly file
Dim oAsmDoc As AssemblyDocument
Set oAsmDoc = ThisApplication.ActiveDocument

Dim oAsmName As String
oAsmName = Left(oAsmDoc.DisplayName, Len(oAsmDoc.DisplayName) - 4)



'check that the active document is an assembly file
If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then

MsgBox ("Please run this rule from the assembly file.")
Exit Sub

End If

'get user input
Result = MsgBox("This will create a DWG file for all of the asembly components that are sheet metal." _
& vbLf & "This rule expects that the part file is saved." _
& vbLf & " " _
& vbLf & "Are you sure you want to create DWG for all of the assembly components?" _
& vbLf & "This could take a while.", vbYesNo, "iLogic - Batch Output DWGs ")

If Result = vbNo Then

Exit Sub

End If

Dim oPath As String
Dim iSplit As Integer

iSplit = InStrRev(oAsmDoc.FullDocumentName, "\")

oPath = Left(oAsmDoc.FullDocumentName, iSplit - 1)

Dim oDataMedium As DataMedium
Set oDataMedium = ThisApplication.TransientObjects.CreateDataMedium

Dim oContext As TranslationContext
Set oContext = ThisApplication.TransientObjects.CreateTranslationContext

oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism

Dim oOptions As NameValueMap
Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap

'get DXF target folder path
Dim oFolder As String
oFolder = oPath & "\" & oAsmName & " Plasma Filer"

'Check for the DXF folder and create it if it does not exist
If Len(Dir(oFolder, vbDirectory)) = 0 Then
MkDir oFolder
End If
'- - - - - - - - - - - - -

'- - - - - - - - - - - - -Component - - - - - - - - - - - -
'look at the files referenced by the assembly
Dim oRefDocs As DocumentsEnumerator

Set oRefDocs = oAsmDoc.AllReferencedDocuments

Dim oRefDoc As Document
Dim iptPathName As String

'work the the drawing files for the referenced models
'this expects that the model has been saved
For Each oRefDoc In oRefDocs

If oRefDoc.DocumentSubType.DocumentSubTypeID = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then

Dim oDrawDoc As PartDocument

Set oDrawDoc = ThisApplication.Documents.Open(oRefDoc.FullDocumentName, True)

oFileName = Left(oRefDoc.DisplayName, Len(oRefDoc.DisplayName) - 4)

'Set the DWG target file name
oDataMedium.FileName = oFolder & "\" & oFileName & ".dwg"

Dim oCompDef As SheetMetalComponentDefinition

Set oCompDef = oDrawDoc.ComponentDefinition

If oCompDef.HasFlatPattern = False Then

oCompDef.Unfold

Else

oCompDef.FlatPattern.Edit

End If

Dim sOut As String

sOut = "FLAT PATTERN DWG?AcadVersion=2004&OuterProfileLayer=Cut&OuterProfileLayerColor=0;255;0&featureprofilesdownLayer=Scribe&featureprofilesdownLayerColor=255;0;255&interiorprofilesLayer=Cut&InvisibleLayers=IV_BEND_DOWN;IV_TANGENT;IV_TOOL_CENTER;IV_TOOL_CENTER_DOWN;IV_ARC_CENTERS;IV_ALTREP_FRONT;IV_ALTREP_BACK;IV_UNCONSUMED_SKETCHES;IV_ROLL_TANGENT;IV_ROLL"


Call oCompDef.DataIO.WriteDataToFile(sOut, oFolder & "\" & oFileName & ".dwg")


'just for check its works coretcly
'i=MessageBox.Show(oDataMedium.FileName, "Title",MessageBoxButtons.OKCancel)

'MessageBox.Show(i,"title",MessageBoxButtons.OK)

'If i=2 Then

'Exit Sub

'End If

oCompDef.FlatPattern.ExitEdit

oDrawDoc.Close

End If
Next
End Sub

 

0 Likes
Message 15 of 30

EMVC
Advocate
Advocate

Hello

 

I added this strings so now it create foldet of thickness and material, but there is something strange we use mm in Norway, in picture below the one folder says 0,500 mm this is 10 mm

The other says Steps sheet tinkness thid is 5 mm

Tykkelse.JPG

Dim oDef As SheetMetalComponentDefinition
Set oDef = oDrawDoc.ComponentDefinition

Dim oThick As String
oThick = oDef.ActiveSheetMetalStyle.Thickness

Dim oMaterial As String
oMaterial = oDrawDoc.ActiveMaterial.DisplayName

oFolder = oPath & "\" & oAsmName & " Plasma Filer\" & oThick & "-" & oMaterial

'Check for the DXF folder and create it if it does not exist
If Len(Dir(oFolder, vbDirectory)) = 0 Then
MkDir oFolder
End If

 

0 Likes
Message 16 of 30

EMVC
Advocate
Advocate

Hello

 

i solved everything except mirror on part, so dont care reading the rest of my posts

So everything else works like a charm

 

 

Sub Export_Plasma()
'define the active document as an assembly file
Dim oAsmDoc As AssemblyDocument
Set oAsmDoc = ThisApplication.ActiveDocument

Dim oAsmName As String
oAsmName = Left(oAsmDoc.DisplayName, Len(oAsmDoc.DisplayName) - 4)



'check that the active document is an assembly file
If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then

MsgBox ("Please run this rule from the assembly file.")
Exit Sub

End If

'get user input
Result = MsgBox("This will create a DWG file for all of the asembly components that are sheet metal." _
& vbLf & "This rule expects that the part file is saved." _
& vbLf & " " _
& vbLf & "Are you sure you want to create DWG for all of the assembly components?" _
& vbLf & "This could take a while.", vbYesNo, "iLogic - Batch Output DWGs ")

If Result = vbNo Then

Exit Sub

End If

Dim oPath As String
Dim iSplit As Integer

iSplit = InStrRev(oAsmDoc.FullDocumentName, "\")

oPath = Left(oAsmDoc.FullDocumentName, iSplit - 1)

Dim oDataMedium As DataMedium
Set oDataMedium = ThisApplication.TransientObjects.CreateDataMedium

Dim oContext As TranslationContext
Set oContext = ThisApplication.TransientObjects.CreateTranslationContext

oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism

Dim oOptions As NameValueMap
Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap

'get DXF target folder path
Dim oFolder As String
oFolder = oPath & "\" & oAsmName & " Plasma Filer"

'Check for the DXF folder and create it if it does not exist
If Len(Dir(oFolder, vbDirectory)) = 0 Then
MkDir oFolder
End If
'- - - - - - - - - - - - -

'- - - - - - - - - - - - -Component - - - - - - - - - - - -
'look at the files referenced by the assembly
Dim oRefDocs As DocumentsEnumerator

Set oRefDocs = oAsmDoc.AllReferencedDocuments

Dim oRefDoc As Document
Dim iptPathName As String

'work the the drawing files for the referenced models
'this expects that the model has been saved
For Each oRefDoc In oRefDocs

If oRefDoc.DocumentSubType.DocumentSubTypeID = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then

Dim oDrawDoc As PartDocument

Set oDrawDoc = ThisApplication.Documents.Open(oRefDoc.FullDocumentName, True)

Dim oDef As SheetMetalComponentDefinition
Set oDef = oDrawDoc.ComponentDefinition

Dim oThick As String
oThick = oDef.ActiveSheetMetalStyle.Thickness

Dim oMaterial As String
oMaterial = oDrawDoc.ActiveMaterial.DisplayName

oFolder = oPath & "\" & oAsmName & " Plasma Filer\" & oThickness & "-" & oMaterial

'Check for the DXF folder and create it if it does not exist
If Len(Dir(oFolder, vbDirectory)) = 0 Then
MkDir oFolder
End If

oFileName = Left(oRefDoc.DisplayName, Len(oRefDoc.DisplayName) - 4)

'Set the DWG target file name
oDataMedium.FileName = oFolder & "\" & oFileName & ".dwg"

Dim oCompDef As SheetMetalComponentDefinition

Set oCompDef = oDrawDoc.ComponentDefinition

If oCompDef.HasFlatPattern = False Then

oCompDef.Unfold

Else

oCompDef.FlatPattern.Edit

End If

Dim sOut As String

sOut = "FLAT PATTERN DWG?AcadVersion=2004&OuterProfileLayer=Cut&OuterProfileLayerColor=0;255;0&featureprofilesdownLayer=Scribe&featureprofilesdownLayerColor=255;0;255&interiorprofilesLayer=Cut&InvisibleLayers=IV_BEND_DOWN;IV_TANGENT;IV_TOOL_CENTER;IV_TOOL_CENTER_DOWN;IV_ARC_CENTERS;IV_ALTREP_FRONT;IV_ALTREP_BACK;IV_UNCONSUMED_SKETCHES;IV_ROLL_TANGENT;IV_ROLL"


Call oCompDef.DataIO.WriteDataToFile(sOut, oFolder & "\" & oFileName & ".dwg")


'just for check its works coretcly
'i=MessageBox.Show(oDataMedium.FileName, "Title",MessageBoxButtons.OKCancel)

'MessageBox.Show(i,"title",MessageBoxButtons.OK)

'If i=2 Then

'Exit Sub

'End If

oCompDef.FlatPattern.ExitEdit

oDrawDoc.Close

End If
Next
End Sub

 

0 Likes
Message 17 of 30

EMVC
Advocate
Advocate

Hello

 

i was played a little bit and it seems like i have front view i wish to have back view instead

 

what lines could be added

0 Likes
Message 18 of 30

chandra.shekar.g
Autodesk Support
Autodesk Support

@EMVC ,

 

Thanks for letting me know that you have solved all your problems.

 

Can you please explain back view and front view issue with screenshots?

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 19 of 30

EMVC
Advocate
Advocate

Hello

 

Here is pictures the first one below is right the second one with green and pink color is mirror, thats my cut and scribe lines, like it is now it will get scribe on the wrong side in plasma, so i mirror in autocad

 

One question, can qty from i propert be added

 

Back.JPGFront.JPG

0 Likes
Message 20 of 30

chandra.shekar.g
Autodesk Support
Autodesk Support

@EMVC,

 

Is it main assembly(TB747 12039__TR_1.iam) exported to dwg?

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes