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: 

Ilogic Copy of Sketched Symbol from template IDW to IDW

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
RobABerger
2787 Views, 8 Replies

Ilogic Copy of Sketched Symbol from template IDW to IDW

I've searched the forum and seen several posts which were helpful, but I keep running into my own ignorance and can't quite get things to work.  There will be several ways to solve this, some more robust than others.  Right now I'd just like to get it working as simply as possible!

 

I want to have a template IDW containing sketched symbols representing various possible drawing status stamps; when the drawing is ready for publish I want to run a rule which allows selection of one stamp for insertion on the drawing.  For right now, I'm just interested in how to copy the symbol from the one drawing to the other.  Here is my nonworking code:

'Query stamp insertion requirement
question = MessageBox.Show("Do you want to insert a stamp?", "Stamp Requirement",MessageBoxButtons.YesNo,MessageBoxIcon.Question)

	If question = vbYes Then
		Dim strSelectedStamp As String = "Result2"
		Dim strStampList As New ArrayList
		strStampRequired = True
		strStampList.Add("F&C Stamp Round")
		strStampList.Add("As-Built Stamp Round")
		strStampList.Add("Test")
		strSelectedStamp = InputListBox("Please select a stamp.", strStampList, strSelectedStamp, "Stamp Selection", "Available Stamps")
		Dim strDrawDoc As Inventor.DrawingDocument: strDrawingDoc = ThisApplication.ActiveDocument
		Dim SourceFile As String = "D:\Local Server\Data\Autodesk Customization\Templates\IV2014Stamps.idw"
		Dim strSourceIDW As DrawingDocument
		strSourceIDW = ThisApplication.Documents.Open(SourceFile, False)
		Dim symbolDef As SketchedSymbolDefinition
		For Each symbolDef In strSourceIDW.SketchedSymbolDefinitions
			If (StrComp(symbolDef.Name,strSelectedStamp,vbTextCompare)=0)Then
				CopyFrom = symbolDef.CopyTo(strDrawDoc, True)
			End If
		Next

 

I get a 'The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))' error.  Any ideas what I am doing wrong and how to fix it?

 

Thanks for the help!

8 REPLIES 8
Message 2 of 9
Mike.Wohletz
in reply to: RobABerger

try this out and let me know if it is what you are looking for.

 

 

 'Query stamp insertion requirement
        question = MessageBox.Show("Do you want to insert a stamp?", "Stamp Requirement", MessageBoxButtons.YesNo, MessageBoxIcon.Question)

        If question = vbYes Then
            Dim strSelectedStamp As String = "Result2"
            Dim strStampList As New ArrayList
            strStampRequired = True
            'strStampList.Add("F&C Stamp Round")
            'strStampList.Add("As-Built Stamp Round")
            'strStampList.Add("Test")
            'strSelectedStamp = InputListBox("Please select a stamp.", strStampList, strSelectedStamp, "Stamp Selection", "Available Stamps")
            Dim strDrawDoc As Inventor.DrawingDocument = ThisApplication.ActiveDocument
            Dim SourceFile As String = "D:\Local Server\Data\Autodesk Customization\Templates\IV2014Stamps.idw"
                     
            Dim strSourceIDW As DrawingDocument
            strSourceIDW = ThisApplication.Documents.Open(SourceFile, False)
            Dim symbolDef As SketchedSymbolDefinition

            For Each symbolDef In strSourceIDW.SketchedSymbolDefinitions
                strStampList.Add(symbolDef.Name)
            Next
strSelectedStamp = InputListBox("Please select a stamp.", strStampList, strSelectedStamp, "Stamp Selection", "Available Stamps")
            For Each symbolDef In strSourceIDW.SketchedSymbolDefinitions
                If (StrComp(symbolDef.Name, strSelectedStamp, vbTextCompare) = 0) Then
                    CopyFrom = symbolDef.CopyTo(strDrawDoc, True)
                End If
            Next
            strSourceIDW.Close()

        End If

 

Message 3 of 9
RobABerger
in reply to: Mike.Wohletz

Thanks for that!  It worked beautifully, and better than I expected.  May I ask another question, or should I post under a new topic?

 

Later in my code I want to take the selected symbol and place it on a drawing sheet.  If I code in the symbol name where I show XXXXX below, it inserts the symbol as expected.  How do I get it to insert the selected symbol using a string/variable?

 

'Insert stamp if required
If strStampRequired = True Then
	Dim strDrawDoc As DrawingDocument = ThisDrawing.Document
	Dim strSketchedSymbolDef As SketchedSymbolDefinition = strDrawDoc.SketchedSymbolDefinitions.Item(XXXXX)
	Dim strTransGeom = ThisApplication.TransientGeometry
	Dim strInsertionPoint As Point2d = strTransGeom.CreatePoint2d(5.5,13)
	Dim strSketchedSymbol As SketchedSymbol = strSheet.SketchedSymbols.Add(strSketchedSymbolDef,strInsertionPoint,0,0.75,Nothing)
Else 
End If

 

Any ideas how to fix it?  I thought I could substitute strSelectedStamp for the XXXXX, but that causes the earlier code to error with 'Variable 'strSelectedStamp' hides a variable in an enclosing block'  on the line 'Dim strSelectedStamp As String = "Result2".  I'd like to understand what I'm doing wrong...

Message 4 of 9
Mike.Wohletz
in reply to: RobABerger

I think that something like this is what you are after. let me know if this is the proper solution to your question.

 

    Sub Main()
        'Query stamp insertion requirement
        question = MessageBox.Show("Do you want to insert a stamp?", "Stamp Requirement", MessageBoxButtons.YesNo, MessageBoxIcon.Question)

        If question = vbYes Then
            Dim strSelectedStamp As String = "Result2"
            Dim strStampList As New ArrayList
            strStampRequired = True
            'strStampList.Add("F&C Stamp Round")
            'strStampList.Add("As-Built Stamp Round")
            'strStampList.Add("Test")
            'strSelectedStamp = InputListBox("Please select a stamp.", strStampList, strSelectedStamp, "Stamp Selection", "Available Stamps")
            Dim strDrawDoc As Inventor.DrawingDocument = ThisApplication.ActiveDocument
            Dim SourceFile As String = "D:\Local Server\Data\Autodesk Customization\Templates\IV2014Stamps.idw"
            Dim strSourceIDW As DrawingDocument
            strSourceIDW = ThisApplication.Documents.Open(SourceFile, False)
            Dim symbolDef As SketchedSymbolDefinition

            For Each symbolDef In strSourceIDW.SketchedSymbolDefinitions
                strStampList.Add(symbolDef.Name)
            Next
            strSelectedStamp = InputListBox("Please select a stamp.", strStampList, strSelectedStamp, "Stamp Selection", "Available Stamps")
            For Each symbolDef In strSourceIDW.SketchedSymbolDefinitions
                If (StrComp(symbolDef.Name, strSelectedStamp, vbTextCompare) = 0) Then
                    CopyFrom = symbolDef.CopyTo(strDrawDoc, True)

                    If MsgBox("Would you like to place the stamp on the drawing?", MsgBoxStyle.YesNo, "Insert Stamp") = MsgBoxResult.Yes Then
                        'Insert stamp if required
                        InsertSymbol(symbolDef.Name)
                    End If
                End If
            Next
            strSourceIDW.Close()

        End If

    End Sub

    Private Sub InsertSymbol(ByVal SymbName As String)

        Dim strDrawDoc As DrawingDocument = ThisDrawing.Document
        Dim strSheet As Sheet = strDrawDoc.ActiveSheet
        Dim strSketchedSymbolDef As SketchedSymbolDefinition = strDrawDoc.SketchedSymbolDefinitions.Item(SymbName)
        Dim strTransGeom = ThisApplication.TransientGeometry
        Dim strInsertionPoint As Point2d = strTransGeom.CreatePoint2d(5.5, 13)
        Dim strSketchedSymbol As SketchedSymbol = strSheet.SketchedSymbols.Add(strSketchedSymbolDef, strInsertionPoint, 0, 0.75, Nothing)

    End Sub

 

Message 5 of 9
RobABerger
in reply to: Mike.Wohletz

Thanks again!  Your code runs perfectly as intended when I run it as its own rule.

 

Unfortunately, I am doing some things in between loading the symbol and placing it on the sheet.  I'll try to describe, rather than posting the whole rule as it is quite long and probably terrible.

 

We prefer to use multisheet IDWs.  The limiting factor historically has been a populated titleblock for each sheet: the file sizes and memory requirements were just too burdensome, so operationally had a macro which split the idw into individual IV.dwg sheets and then added the titleblock populated from a spreadsheet.  The spreadsheet is nice; it tracks our revision history for an entire document set.

 

Now we are trying something similar in iLogic, and my rule first specifies the border, titleblock, and stamp (which will be the same for all sheets) and then steps through each sheet adding the border, titleblock and stamp if required, populates the titleblock with custom iproperties read in from the spreadsheet, saves/exports the resultant to ACAD dwg and pdf, and then deletes the same from that sheet before continuing to the next sheet.  At any given time, the IDW custom iProperties contain sufficient data to populate only one sheet's titleblock.

 

Consequently, I'd like to call subInsertSymbol to the active sheet immediately before the sheet is exported, but if I move InsertSymbol(symbolDef.Name) it seems symbolDef becomes 'not declared'...at least that is the error I am getting.  Here is just a snip of the code showing the last of assigning values to the iProperties through to the start of publishing, all in Sub Main():

 

iProperties.Value("Custom", "PROJECTTITLE1-2") = strProjTitle2
iProperties.Value("Custom", "FILENUM2") = strFileNum2
iProperties.Value("Custom", "AREA/FACILITY") = strAreaFac
iProperties.Value("Custom", "DOC/TYPE") = strDocType

'Insert the border on the active sheet
ActiveSheet.Border = "HEL"

'Insert the titleblock on the active sheet
ActiveSheet.TitleBlock = strSelectedTB

'Insert stamp if required
If strStampRequired = True Then
	InsertSymbol(symbolDef.Name)
	'Dim strDrawDoc As DrawingDocument = ThisDrawing.Document
	'Dim strSketchedSymbolDef As SketchedSymbolDefinition = strDrawDoc.SketchedSymbolDefinitions.Item(strSelectedStamp)
	'Dim strTransGeom = ThisApplication.TransientGeometry
	'Dim strInsertionPoint As Point2d = strTransGeom.CreatePoint2d(5.5,13)
	'Dim strSketchedSymbol As SketchedSymbol = strSheet.SketchedSymbols.Add(strSketchedSymbolDef,strInsertionPoint,0,0.75,Nothing)
Else 
End If

MessageBox.Show("All properties have been applied to " & strCurrentSeqNum, "Title Block Data Status")

'---------------Export the sheet to pdf------------------------

'Assign path and file name
strFullFileName = strPdfFolder & "\" & strFileNum2 & ".pdf"

strPDFAddIn = ThisApplication.ApplicationAddIns.ItemById _
("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
strDocument = ThisApplication.ActiveDocument

 

Am I declaring symbolDef in the wrong location for it to be available throughout?

 

Message 6 of 9
RobABerger
in reply to: RobABerger

Here's the entire rule...I've put <snipped for length> where I've taken out repetitive data&colon;

 

Public Sub Main()
'Check if publish rule intentional
 
question = MessageBox.Show("Ready to commence publishing?", "Confirm Publish",MessageBoxButtons.YesNo,MessageBoxIcon.Question)

	If question = vbNo Then
    Return
	Else
    End If

'Define pdf and dwg file locations

strPublishedFolder = ThisDoc.Path & "\Published"

'Make output folders if they don't exist
    strPdfFolder = strPublishedFolder & "\PDF"
    If Dir(strPdfFolder, vbDirectory) = "" Then MkDir (strPdfFolder)
    strDwgFolder = strPublishedFolder & "\DWG"
    If Dir(strDwgFolder, vbDirectory) = "" Then MkDir (strDwgFolder)
	
'Title block selection from external file
ThisDrawing.ResourceFileName = "D:\Local Server\Data\Autodesk Customization\Templates\IV2014TitleBlocks.idw"
ThisDrawing.KeepExtraResources = False

Dim strSelectedTB As String = "Result"
Dim strTitleBlock As New ArrayList
strTitleBlock.Add("EMAL")
strTitleBlock.Add("EmalP2")
strTitleBlock.Add("KMP")

strSelectedTB = InputListBox("Select a Title Block", strTitleBlock, strSelectedTB, "Title Block Selection", "Available Title Blocks")

'Query stamp insertion requirement
question = MessageBox.Show("Do you want to insert a stamp?", "Stamp Requirement", MessageBoxButtons.YesNo, MessageBoxIcon.Question)

    If question = vbYes Then
        Dim strSelectedStamp As String = "Result2"
        Dim strStampList As New ArrayList
        strStampRequired = True
        Dim strDrawDoc As Inventor.DrawingDocument = ThisApplication.ActiveDocument
        Dim SourceFile As String = "D:\Local Server\Data\Autodesk Customization\Templates\IV2014Stamps.idw"
                     
        Dim strSourceIDW As DrawingDocument
        strSourceIDW = ThisApplication.Documents.Open(SourceFile, False)
        Dim symbolDef As SketchedSymbolDefinition

        For Each symbolDef In strSourceIDW.SketchedSymbolDefinitions
            strStampList.Add(symbolDef.Name)
        Next
		strSelectedStamp = InputListBox("Please select a stamp.", strStampList, strSelectedStamp, "Stamp Selection", "Available Stamps")
        For Each symbolDef In strSourceIDW.SketchedSymbolDefinitions
            If (StrComp(symbolDef.Name, strSelectedStamp, vbTextCompare) = 0) Then
                CopyFrom = symbolDef.CopyTo(strDrawDoc, True)
            End If
        Next
        strSourceIDW.Close()
		MessageBox.Show("You have selected " & strSelectedStamp, "Stamp Selection Feedback")
		Else
			strStampRequired = False
    End If

'Step through each sheet in the IDW
Dim strSheets As Sheets
strSheets = ThisDoc.Document.sheets
Dim strSheet As Sheet
For Each strSheet In strSheets
	strSheet.activate

'Truncate the sheet instance from the sheet name, keeping the digits before the colon
SheetName = ActiveSheet.Name
ColonIndex = SheetName.LastindexOf(":")
strCurrentSeqNum = SheetName.substring(0,ColonIndex)

'Access the Titleblock Data spreadsheet and select the row corresponding to the active drawing sheet
i = GoExcel.FindRow("TBData.xlsx", "Sheet1", "SEQNO", "=", strCurrentSeqNum)

'Get the cell values for the designated row
strArea = GoExcel.CurrentRowValue("AREA")
<snipped for length>
strDocType = GoExcel.CurrentRowValue("DOC/TYPE")

'Populate the Custom iProperties with the TBData values
iProperties.Value("Custom", "AREA") = strArea
<snipped for length>
iProperties.Value("Custom", "DOC/TYPE") = strDocType

'Insert the border on the active sheet
ActiveSheet.Border = "HEL"

'Insert the titleblock on the active sheet
ActiveSheet.TitleBlock = strSelectedTB

'Insert stamp if required
If strStampRequired = True Then
	InsertSymbol(symbolDef.Name)
	'Dim strDrawDoc As DrawingDocument = ThisDrawing.Document
	'Dim strSketchedSymbolDef As SketchedSymbolDefinition = strDrawDoc.SketchedSymbolDefinitions.Item(strSelectedStamp)
	'Dim strTransGeom = ThisApplication.TransientGeometry
	'Dim strInsertionPoint As Point2d = strTransGeom.CreatePoint2d(5.5,13)
	'Dim strSketchedSymbol As SketchedSymbol = strSheet.SketchedSymbols.Add(strSketchedSymbolDef,strInsertionPoint,0,0.75,Nothing)
	Else 
End If

MessageBox.Show("All properties have been applied to " & strCurrentSeqNum, "Title Block Data Status")

'---------------Export the sheet to pdf------------------------

'Assign path and file name
strFullFileName = strPdfFolder & "\" & strFileNum2 & ".pdf"

strPDFAddIn = ThisApplication.ApplicationAddIns.ItemById _
("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
strDocument = ThisApplication.ActiveDocument
strContext = ThisApplication.TransientObjects.CreateTranslationContext
strContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
strOptions = ThisApplication.TransientObjects.CreateNameValueMap
strDataMedium = ThisApplication.TransientObjects.CreateDataMedium 

If strPDFAddIn.HasSaveCopyAsOptions(strDataMedium, strContext, strOptions) Then
strOptions.Value("All_Color_AS_Black") = 0
strOptions.Value("Remove_Line_Weights") = 0
strOptions.Value("Vector_Resolution") = 400
strOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintCurrentSheet
End If 

'Set the PDF target file name
strDataMedium.FileName = strFullFileName 

'Publish document as PDF
strPDFAddIn.SaveCopyAs(strDocument, strContext, strOptions, strDataMedium) 

'----------- export the sheet to dwg -------------------
'Assign path and file name
strFullFileName = strDwgFolder & "\" & strFileNum2 & ".dwg"

' Get the DWG translator Add-In. 
strDWGAddIn = ThisApplication.ApplicationAddIns.ItemById _
("{C24E3AC4-122E-11D5-8E91-0010B541CD80}") 
strContext = ThisApplication.TransientObjects.CreateTranslationContext 
strContext.Type = IOMechanismEnum.kFileBrowseIOMechanism 
strOptions = ThisApplication.TransientObjects.CreateNameValueMap 
strDataMedium = ThisApplication.TransientObjects.CreateDataMedium 

' Check whether the translator has 'SaveCopyAs' options 
If strDWGAddIn.HasSaveCopyAsOptions(strDocument, strContext, strOptions) Then 
    ' DWG version.
    ' 23 = ACAD 2000
    ' 25 = ACAD 2004
    ' 27 = ACAD 2007
    ' 29 = ACAD 2010 
    strOptions.Value("DwgVersion") = 27
	Dim strIniFile As String 
	strIniFile = "D:\Local Server\Data\Heaslip Autodesk Customization\Templates\DWGSubmittalConfig.ini" 

	' Create the name-value that specifies the ini file to use. 
	strOptions.Value("Export_Acad_IniFile") = strIniFile 
End If

'Set the DWG target file name
strDataMedium.FileName = strFullFileName

'Publish the active sheet as DWG 2007
strDWGAddIn.SaveCopyAs(strDocument, strContext, strOptions, strDataMedium)

'Delete the titleblock, border, and stamp from the current sheet before continuing to the next sheet
strSheet.TitleBlock.Delete()
strSheet.Border.Delete()

'MessageBox.Show("Sheet " & strCurrentSeqNum & " has successfully been exported", "Sheet Publish Status")

Next

MessageBox.Show("Publishing Completed","")
End Sub

Private Sub InsertSymbol(ByVal SymbName As String)

    Dim strDrawDoc As DrawingDocument = ThisDrawing.Document
    Dim strSheet As Sheet = strDrawDoc.ActiveSheet
    Dim strSketchedSymbolDef As SketchedSymbolDefinition = strDrawDoc.SketchedSymbolDefinitions.Item(SymbName)
    Dim strTransGeom = ThisApplication.TransientGeometry
    Dim strInsertionPoint As Point2d = strTransGeom.CreatePoint2d(5.5, 13)
    Dim strSketchedSymbol As SketchedSymbol = strSheet.SketchedSymbols.Add(strSketchedSymbolDef, strInsertionPoint, 0, 0.75, Nothing)

End Sub

 Thanks...

Message 7 of 9
Mike.Wohletz
in reply to: RobABerger

Ok I see that the property is declared inside an IF statement and then tried to be used outside of that. This is not posible to do insise of an IF or loop so when this is the case you will need to set something of a declared variable or public property decalared outside of this to make it available through the process. I have included that I think will work for you below. 

 

 

    Public Sub Main()
        'Check if publish rule intentional
        Dim SymbolName As String = Nothing ' we are going to declare this and set it to nothing early in the game and use it later
        question = MessageBox.Show("Ready to commence publishing?", "Confirm Publish", MessageBoxButtons.YesNo, MessageBoxIcon.Question)

        If question = vbNo Then
            Return
        Else
        End If

        'Define pdf and dwg file locations

        strPublishedFolder = ThisDoc.Path & "\Published"

        'Make output folders if they don't exist
        strPdfFolder = strPublishedFolder & "\PDF"
        If Dir(strPdfFolder, vbDirectory) = "" Then MkDir(strPdfFolder)
        strDwgFolder = strPublishedFolder & "\DWG"
        If Dir(strDwgFolder, vbDirectory) = "" Then MkDir(strDwgFolder)

        'Title block selection from external file
        ThisDrawing.ResourceFileName = "D:\Local Server\Data\Autodesk Customization\Templates\IV2014TitleBlocks.idw"
        ThisDrawing.KeepExtraResources = False

        Dim strSelectedTB As String = "Result"
        Dim strTitleBlock As New ArrayList
        strTitleBlock.Add("EMAL")
        strTitleBlock.Add("EmalP2")
        strTitleBlock.Add("KMP")

        strSelectedTB = InputListBox("Select a Title Block", strTitleBlock, strSelectedTB, "Title Block Selection", "Available Title Blocks")

        'Query stamp insertion requirement
        question = MessageBox.Show("Do you want to insert a stamp?", "Stamp Requirement", MessageBoxButtons.YesNo, MessageBoxIcon.Question)

        If question = vbYes Then
            Dim strSelectedStamp As String = "Result2"
            Dim strStampList As New ArrayList
            strStampRequired = True
            Dim strDrawDoc As Inventor.DrawingDocument = ThisApplication.ActiveDocument
            Dim SourceFile As String = "D:\Local Server\Data\Autodesk Customization\Templates\IV2014Stamps.idw"

            Dim strSourceIDW As DrawingDocument
            strSourceIDW = ThisApplication.Documents.Open(SourceFile, False)
            Dim symbolDef As SketchedSymbolDefinition

            For Each symbolDef In strSourceIDW.SketchedSymbolDefinitions
                strStampList.Add(symbolDef.Name)
            Next
            strSelectedStamp = InputListBox("Please select a stamp.", strStampList, strSelectedStamp, "Stamp Selection", "Available Stamps")
            For Each symbolDef In strSourceIDW.SketchedSymbolDefinitions
                If (StrComp(symbolDef.Name, strSelectedStamp, vbTextCompare) = 0) Then
                    CopyFrom = symbolDef.CopyTo(strDrawDoc, True)
                    SymbolName = symbolDef.Name
                End If
            Next
            strSourceIDW.Close()
            MessageBox.Show("You have selected " & strSelectedStamp, "Stamp Selection Feedback")
        Else
            strStampRequired = False
        End If

        'Step through each sheet in the IDW
        Dim strSheets As Sheets
        strSheets = ThisDoc.Document.sheets
        Dim strSheet As Sheet
        For Each strSheet In strSheets
            strSheet.activate()

            'Truncate the sheet instance from the sheet name, keeping the digits before the colon
            SheetName = ActiveSheet.Name
            ColonIndex = SheetName.LastindexOf(":")
            strCurrentSeqNum = SheetName.substring(0, ColonIndex)

            'Access the Titleblock Data spreadsheet and select the row corresponding to the active drawing sheet
            i = GoExcel.FindRow("TBData.xlsx", "Sheet1", "SEQNO", "=", strCurrentSeqNum)

            'Get the cell values for the designated row
            strArea = GoExcel.CurrentRowValue("AREA")
            '<snipped for length>
            strDocType = GoExcel.CurrentRowValue("DOC/TYPE")

            'Populate the Custom iProperties with the TBData values
            iProperties.Value("Custom", "AREA") = strArea
            '<snipped for length>
            iProperties.Value("Custom", "DOC/TYPE") = strDocType

            'Insert the border on the active sheet
            ActiveSheet.Border = "HEL"

            'Insert the titleblock on the active sheet
            ActiveSheet.TitleBlock = strSelectedTB

            'Insert stamp if required 
            If strStampRequired = True And Not SymbolName Is Nothing Then ' we will make sure it is wanted and also check that the property declared 
                ' at the top of this sub was set to something so we dont pass an empty string
                InsertSymbol(SymbolName)
                'Dim strDrawDoc As DrawingDocument = ThisDrawing.Document
                'Dim strSketchedSymbolDef As SketchedSymbolDefinition = strDrawDoc.SketchedSymbolDefinitions.Item(strSelectedStamp)
                'Dim strTransGeom = ThisApplication.TransientGeometry
                'Dim strInsertionPoint As Point2d = strTransGeom.CreatePoint2d(5.5,13)
                'Dim strSketchedSymbol As SketchedSymbol = strSheet.SketchedSymbols.Add(strSketchedSymbolDef,strInsertionPoint,0,0.75,Nothing)
            Else
            End If

            MessageBox.Show("All properties have been applied to " & strCurrentSeqNum, "Title Block Data Status")

            '---------------Export the sheet to pdf------------------------

            'Assign path and file name
            strFullFileName = strPdfFolder & "\" & strFileNum2 & ".pdf"

            strPDFAddIn = ThisApplication.ApplicationAddIns.ItemById _
            ("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
            strDocument = ThisApplication.ActiveDocument
            strContext = ThisApplication.TransientObjects.CreateTranslationContext
            strContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
            strOptions = ThisApplication.TransientObjects.CreateNameValueMap
            strDataMedium = ThisApplication.TransientObjects.CreateDataMedium

            If strPDFAddIn.HasSaveCopyAsOptions(strDataMedium, strContext, strOptions) Then
                strOptions.Value("All_Color_AS_Black") = 0
                strOptions.Value("Remove_Line_Weights") = 0
                strOptions.Value("Vector_Resolution") = 400
                strOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintCurrentSheet
            End If

            'Set the PDF target file name
            strDataMedium.FileName = strFullFileName

            'Publish document as PDF
            strPDFAddIn.SaveCopyAs(strDocument, strContext, strOptions, strDataMedium)

            '----------- export the sheet to dwg -------------------
            'Assign path and file name
            strFullFileName = strDwgFolder & "\" & strFileNum2 & ".dwg"

            ' Get the DWG translator Add-In. 
            strDWGAddIn = ThisApplication.ApplicationAddIns.ItemById _
            ("{C24E3AC4-122E-11D5-8E91-0010B541CD80}")
            strContext = ThisApplication.TransientObjects.CreateTranslationContext
            strContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
            strOptions = ThisApplication.TransientObjects.CreateNameValueMap
            strDataMedium = ThisApplication.TransientObjects.CreateDataMedium

            ' Check whether the translator has 'SaveCopyAs' options 
            If strDWGAddIn.HasSaveCopyAsOptions(strDocument, strContext, strOptions) Then
                ' DWG version.
                ' 23 = ACAD 2000
                ' 25 = ACAD 2004
                ' 27 = ACAD 2007
                ' 29 = ACAD 2010 
                strOptions.Value("DwgVersion") = 27
                Dim strIniFile As String
                strIniFile = "D:\Local Server\Data\Heaslip Autodesk Customization\Templates\DWGSubmittalConfig.ini"

                ' Create the name-value that specifies the ini file to use. 
                strOptions.Value("Export_Acad_IniFile") = strIniFile
            End If

            'Set the DWG target file name
            strDataMedium.FileName = strFullFileName

            'Publish the active sheet as DWG 2007
            strDWGAddIn.SaveCopyAs(strDocument, strContext, strOptions, strDataMedium)

            'Delete the titleblock, border, and stamp from the current sheet before continuing to the next sheet
            strSheet.TitleBlock.Delete()
            strSheet.Border.Delete()

            'MessageBox.Show("Sheet " & strCurrentSeqNum & " has successfully been exported", "Sheet Publish Status")

        Next

        MessageBox.Show("Publishing Completed", "")
End Sub

    Private Sub InsertSymbol(ByVal SymbName As String)

        Dim strDrawDoc As DrawingDocument = ThisDrawing.Document
        Dim strSheet As Sheet = strDrawDoc.ActiveSheet
        Dim strSketchedSymbolDef As SketchedSymbolDefinition = strDrawDoc.SketchedSymbolDefinitions.Item(SymbName)
        Dim strTransGeom = ThisApplication.TransientGeometry
        Dim strInsertionPoint As Point2d = strTransGeom.CreatePoint2d(5.5, 13)
        Dim strSketchedSymbol As SketchedSymbol = strSheet.SketchedSymbols.Add(strSketchedSymbolDef, strInsertionPoint, 0, 0.75, Nothing)
    End Sub

 

Message 8 of 9
RobABerger
in reply to: Mike.Wohletz

Hi Mike, that worked great.  Thank you very much for all the help!

Message 9 of 9

Hi,

Could you help me. How to create ilogic rule for One Sketched Symbol without messege:

MessageBox.Show("Do you want to insert a stamp?
("Would you like to place the stamp on the drawing?

 

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

Post to forums  

Autodesk Design & Make Report