- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I have been trying to write an iLogic rule to automate the process of exporting a selected face to a dxf file.
The file name and location is set using information from iproperties and project values.
I have searched this forum and the web in general but cant seem to find an answer to my problem.
My background in coding is from autocad lisp (enough to get me by), maybe this is confusing my understanding of iLogic.
Maybe the code i have found is for VB and not iLogic.
With all the examples i have referenced I have been unable to see any link between the select face function and the export function.
How does "GeomToDXFCommand" know what face you have selected?
With the code I have everything seems to work except the actual export function.
When i run the rule from the iLogic Browser (right click, run), i get prompted to select a face.
I select the face i want to export and then nothing.
If I then right click and select "Export Face As" a dxf file with the correct filename is created in the project folder in a folder called "DXF".
This happens without and dialog box or prompts, as I would expect if the ilogic rule ran correctly.
Any help with coding or my understanding of the code would be greatly appreciated.
Here is my code, it is a work in progress so it may be a bit untidy.
I have also attached the ilogic file.
'check that this active document is a part file
'[ ;Part Check
Imports System.Windows.Forms
If ThisApplication.ActiveDocument.DocumentType <> kPartDocumentObject Then
MessageBox.Show ("Please open a part document", "iLogic")
End If
']
'[ ;Set Variables
oPath = ThisDoc.Path
''Set a reference to the active document (the document to be published).
Dim oDocument As Document = ThisApplication.ActiveDocument
'' Create a DataMedium object
Dim oDataMedium As DataMedium = ThisApplication.TransientObjects.CreateDataMedium
oQty = iProperties.Value(docFName, "Project", "Stock Number")
oMat = iProperties.Value(docFName, "Summary", "Comments")
oFolder = oPath & "\DXF\"
oFileName = ThisDoc.FileName(False) & " - "& oMat & " - " & oQty & " Required.dxf" 'without extension
''Check for the DXF folder and create it if it does not exist
If Not System.IO.Directory.Exists(oFolder) Then
System.IO.Directory.CreateDirectory(oFolder)
End If
''Set the dxf target file name
oDataMedium.FileName = oFolder & oFilename
DefaultChoice = True
'MessageBox.Show(oDataMedium.FileName)
''copies filename to clipboard for paste (ctrl + v)
'Clipboard.SetText(oFileName)
']
'[;Selection Code
Dim testFace As Face
Try
testFace = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select a face")
Catch ex As Exception
End Try
If (testFace Is Nothing) Then
Return
End If
']
'[;Export code 1
'Get CommandManager object
'Dim Cm As CommandManager
'Cm = ThisApplication.CommandManager
Dim Cm As CommandManager = ThisApplication.CommandManager
Cm.PostPrivateEvent(PrivateEventTypeEnum.kFileNameEvent, oDataMedium.FileName)
'Get control definition for the line command.
'Dim oCDef As ControlDefinition = Cm.ControlDefinitions.Item( "GeomToDXFCommand")
'oCDef.Execute()
'''at this point i can right click on face and select 'Export as face' and it will be saved properly
'''without any further input.
'''Its Almost as if the selected face isn't being parsed to the GeomToDXFCommand.
']
'[;Clear Variables
oPath = Nothing
oDocument = Nothing
oDataMedium = Nothing
oQty = Nothing
oMat = Nothing
oFolder = Nothing
oFileName = Nothing
testFace = Nothing
']
Solved! Go to Solution.