Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

dxf again

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
GosponZ
346 Views, 2 Replies

dxf again

Hi,

this code working perfect. This is for multi sheets. But here is problem i need you guys to help me please. When i run this rule it ask me if i want to save . If i click yes it will save dxf with sheet name as i wanted. If i click no it will exit. What i would like is if i click No to skip that sheet and go to next sheet. Is that somehow possible?

I made test folder on my c drive

Thanks for any help.

 

oPath = ThisDoc.Path

oFileName = ThisDoc.FileName(False) 'without extension

oDXFAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC4-122E-11D5-8E91-0010B541CD80}")

oDocument = ThisApplication.ActiveDocument

oContext = ThisApplication.TransientObjects.CreateTranslationContext

oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism

oOptions = ThisApplication.TransientObjects.CreateNameValueMap

oDataMedium = ThisApplication.TransientObjects.CreateDataMedium

 

 

'Define the drawing

Dim oDrawing As DrawingDocument

oDrawing = ThisDoc.Document

 

Dim oSheet As Sheet

Dim lPos As Long

Dim rPos As Long

Dim sLen As Long

Dim sSheetName As String

Dim sSheetNumber As Integer

 

'step through each drawing sheet

For Each oSheet In oDrawing.Sheets

 

'find the seperator in the sheet name:number

lPos = InStr(oSheet.Name, ":")

 

'find the number of characters in the sheet name

sLen = Len(oSheet.Name)

 

'find the sheet name

sSheetName = Left(oSheet.Name, lPos -1)

 

'find the sheet number

sSheetNumber = Right(oSheet.Name, sLen -lPos)

 

'get DXF target folder path

oFolder = "C:\Test Folder"

 

'Set the DXF target file name

oDataMedium.FileName = oFolder & "\" &  " " & sSheetName & " " & sSheetNumber  & ".dxf"

'//////////////////////////

response = MessageBox.Show("Do you want to save this file?", "Reminder",MessageBoxButtons.YesNo)

If response = vbNo Then Exit Sub

'///////////////////

'Publish document

'Confirmation message

MessageBox.Show("DXF SAVED TO: " & oDataMedium.FileName, "DXF Saved", MessageBoxButtons.OK)

 

'Publish document

oDXFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)

Next

2 REPLIES 2
Message 2 of 3
Passi
in reply to: GosponZ

I don't know, if i got the question correctly 🙂 Because you already have the solution on your screen with only one line missing?!?

 

So I try, but don't be angry, if the answer is not the correct one 🙂 I done this in iLogic, because it's a little bit easier to answer quick.

 

It should be something like this:

 

oDrawing = ThisApplication.ActiveDocument

Dim Answer As MsgboxResult

For Each oSheet In oDrawing.Sheets
Answer = Msgbox("Yes = Save or No = Continue to next Sheet?",MsgBoxStyle.YesNo,"Question")
If Answer = MsgBoxResult.Yes
'Save Function
Else if Answer = MsgBoxResult.No
'Continue to the next Page
End if
Next

the continue in your case is only nothing 🙂 because the next do this job.

 

I think, you code has to be this:

 

        oPath = ThisDoc.Path

        oFileName = ThisDoc.FileName(False) 'without extension

        oDXFAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC4-122E-11D5-8E91-0010B541CD80}")

        oDocument = ThisApplication.ActiveDocument

        oContext = ThisApplication.TransientObjects.CreateTranslationContext

        oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism

        oOptions = ThisApplication.TransientObjects.CreateNameValueMap

        oDataMedium = ThisApplication.TransientObjects.CreateDataMedium





        'Define the drawing 

        Dim oDrawing As DrawingDocument

        oDrawing = ThisDoc.Document



        Dim oSheet As Sheet

        Dim lPos As Long

        Dim rPos As Long

        Dim sLen As Long

        Dim sSheetName As String

        Dim sSheetNumber As Integer



        'step through each drawing sheet

Dim Response As MsgboxResult

        For Each oSheet In oDrawing.Sheets

            Response = MsgBox("Yes = Save or No = Continue to next Sheet?", MsgBoxStyle.YesNo, "Question")
            If Response = MsgBoxResult.Yes Then

                'find the seperator in the sheet name:number

                lPos = InStr(oSheet.Name, ":")



                'find the number of characters in the sheet name

                sLen = Len(oSheet.Name)



                'find the sheet name

                sSheetName = Left(oSheet.Name, lPos - 1)



                'find the sheet number

                sSheetNumber = Right(oSheet.Name, sLen - lPos)



                'get DXF target folder path

                oFolder = "C:\Test Folder"



                'Set the DXF target file name

                oDataMedium.FileName = oFolder & "\" & " " & sSheetName & " " & sSheetNumber & ".dxf"


                MessageBox.Show("DXF SAVED TO: " & oDataMedium.FileName, "DXF Saved", MessageBoxButtons.OK)

                'Publish document

                oDXFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)

            End If
        Next

 

Correct?

Message 3 of 3
GosponZ
in reply to: Passi

Many thanks this is what i needSmiley Happy

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report