05-22-2017
05:49 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
05-22-2017
05:49 AM
Hi Jason,
Please find a sample iLogic code in the following.
Sub Main()
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
oSheet = oDrawDoc.Sheets.Item(1)
Dim obj As DrawingCurveSegment
obj = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Select circle to create punch")
obj.Visible = False
Dim oCircleCurve As DrawingCurve
For Each oCurve As DrawingCurve In oSheet.DrawingViews.Item(1).DrawingCurves
If oCurve.CurveType = CurveTypeEnum.kCircleCurve Then
For Each oSegment As DrawingCurveSegment In oCurve.Segments
If oSegment.Equals(obj) = True Then
oCircleCurve = oCurve
oSegment.Visible = False
Exit For
Exit For
End If
Next
End If
Next
Dim oIntent As GeometryIntent
oIntent = oSheet.CreateGeometryIntent(oCircleCurve)
Dim oCenter As Inventor.Centermark
oCenter = oSheet.Centermarks.Add(oIntent)
DXF_Export()
obj.Visible = True
oCenter.Delete()
End Sub
Private Sub DXF_Export()
' Get the DXF translator Add-In.
Dim DXFAddIn As TranslatorAddIn
DXFAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC4-122E-11D5-8E91-0010B541CD80}")
'Set a reference to the active document (the document to be published).
Dim oDocument As Document
oDocument = ThisApplication.ActiveDocument
Dim oContext As TranslationContext
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
' Create a NameValueMap object
Dim oOptions As NameValueMap
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
' Create a DataMedium object
Dim oDataMedium As DataMedium
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
' Check whether the translator has 'SaveCopyAs' options
If DXFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then
Dim strIniFile As String
strIniFile = "C:\tempDXFOut.ini"
' Create the name-value that specifies the ini file to use.
oOptions.Value("Export_Acad_IniFile") = strIniFile
End If
'Set the destination file name
oDataMedium.FileName = ThisDoc.PathAndFileName(False) & ".dxf"
'Publish document.
Call DXFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
End Sub
On running the code, it asks for a circle to select. After successful selection, a center mark is created on that circle and export to dxf at same location and same file name.
This iLogic code can be extended for multiple selection. It is also can be extended automatic selection of circles which is having lesser radius(for example, 0.5 in radius).
Please feel free to contact if there is any doubt.
If solves your problem, click on "Accept as solution" or give a "Kudo".
Thanks and regards,
CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network
