Create DXF by Selecting Face while Rule Running

Create DXF by Selecting Face while Rule Running

RoyWickrama_RWEI
Advisor Advisor
690 Views
8 Replies
Message 1 of 9

Create DXF by Selecting Face while Rule Running

RoyWickrama_RWEI
Advisor
Advisor

The rule works fine if a surface is pre-selected. However, Ideally, I need the user (without pre-selecting) to select the face while the rule is running (i.e. rule execution reminds user to select a face).

I tried a lot without success. I request someone help me. Simplified code is shown below.   Sample file attached here to!

 

Imports System.Windows.Forms
Dim oFace As Face
Dim formatExport As New ArrayList
oDxf = ".dxf"
oExit = "EXIT"
formatExport.add(oDxf)
formatExport.add(oExit)
oExt = InputListBox("SELECT", formatExport, formatExport(0), Title := "Title", ListName := "List")
If oExt = oExit Then Exit Sub
If oExt = oDxf Then 
	
	i = 0
	While i = 0 'Select one face only
	L_oFace:
	oFace = ThisApplication.CommandManager.Pick(Inventor.SelectionFilterEnum.kPartFaceFilter, "Select face")
		If IsNothing (oFace) Then Goto L_oFace 
		i += 1
		planesSelected = planesSelected _
		& vbLf & "FACE " & i & ", SELECTED"
		MessageBox.Show("Message: " & planesSelected, "Title")
	End While	' oFace Is Nothing
End If

nameFolder = ThisDoc.WorkspacePath() & "\"
Clipboard.SetText(nameFolder)

saveAsFileName = ThisDoc.FileName(False) & oExt
oFileName = nameFolder & saveAsFileName
MessageBox.Show("saveAsFileName: " & oFileName, "Title")

Dim oCmdMgr As CommandManager
oCmdMgr = ThisApplication.CommandManager

Call oCmdMgr.PostPrivateEvent(PrivateEventTypeEnum.kFileNameEvent, oFileName)
Call oCmdMgr.ControlDefinitions.Item("GeomToDXFCommand").Execute 
0 Likes
Accepted solutions (2)
691 Views
8 Replies
Replies (8)
Message 2 of 9

marcin_otręba
Advisor
Advisor

I deleted while because it doesn't do nothing and it works... instead of while you can use if  thisdoc.selectset.count = 0 then:

If oExt = oDxf Then 
	L_oFace:
	oFace = ThisApplication.CommandManager.Pick(Inventor.SelectionFilterEnum.kPartFaceFilter, "Select face")
		If IsNothing (oFace) Then Goto L_oFace 
		planesSelected = planesSelected _
		& vbLf & "FACE " & i & ", SELECTED"
		MessageBox.Show("Message: " & planesSelected, "Title")
End If

 

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

Message 3 of 9

RoyWickrama_RWEI
Advisor
Advisor

Thanks for the posting.

It goes through. But, I do never see any DXF created anywhere.

Although I am not willing to disturb you, could you take a look at. I appreciate your help!

0 Likes
Message 4 of 9

marcin_otręba
Advisor
Advisor

delete msgboxes and it will be ok.:

This is whole code...

 

Dim oFace As Face
L_oFace:
   oFace = ThisApplication.CommandManager.Pick(Inventor.SelectionFilterEnum.kPartFaceFilter, "Select face")
        If oFace Is Nothing Then GoTo L_oFace


oFileName = Left(ThisApplication.ActiveDocument.FullDocumentName, Len(ThisApplication.ActiveDocument.FullDocumentName) - 3) & "dxf"


Dim oCmdMgr As CommandManager
Set oCmdMgr = ThisApplication.CommandManager

Call oCmdMgr.PostPrivateEvent(kFileNameEvent, oFileName)
Call oCmdMgr.ControlDefinitions.Item("GeomToDXFCommand").Execute


Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

Message 5 of 9

RoyWickrama_RWEI
Advisor
Advisor

Thanks. Still dxf not creating! But, likely the procedure not ended. If I try to open another document, following pop-up comes on. I guess the selected face is not compatible for creating dxf.

Could we do with a different selection method?

To Post 10th.png

0 Likes
Message 6 of 9

marcin_otręba
Advisor
Advisor
Please send me newest file with rule

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

Message 7 of 9

RoyWickrama_RWEI
Advisor
Advisor

Thanks a lot.

I attached the file cw the rule.

Please try to help me.

0 Likes
Message 8 of 9

marcin_otręba
Advisor
Advisor
Accepted solution

Call ThisApplication.ActiveDocument.SelectSet.clear()
Dim oFace As Face
L_oFace:
oFace = ThisApplication.CommandManager.Pick(Inventor.SelectionFilterEnum.kPartFaceFilter, "Select face")
If oFace Is Nothing Then Goto L_oFace
Call ThisApplication.ActiveDocument.SelectSet.select(oface)
Dim oCmdMgr As CommandManager
oCmdMgr = ThisApplication.CommandManager

.....

.....

Call oCmdMgr.ClearPrivateEvents()
Call oCmdMgr.PostPrivateEvent(PrivateEventTypeEnum.kFileNameEvent, oFileName)

Call oCmdMgr.ControlDefinitions.Item("GeomToDXFCommand").Execute
Call ThisApplication.ActiveDocument.SelectSet.clear()

 

 

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

Message 9 of 9

RoyWickrama_RWEI
Advisor
Advisor
Accepted solution

Thanks a lot for the extending help until solution. With the help of your informative codes I could get around my need (see below - it works fine). I also learnt some specific codes. I will expand the code for my other needs as well.

 

Imports System.Windows.Forms
Call ThisApplication.ActiveDocument.SelectSet.clear()
Dim oFace As Face
foderDxfSave = "C:\$WF_DHAMAG\Projects\DHAMAG_SDAI\EWE\"
Clipboard.SetText(foderDxfSave)

Dim formatExport As New ArrayList
oDxf = ".dxf"
oPdf = ".pdf"
oSat = ".sat"
oExit = "EXIT"
formatExport.add(oDxf)
formatExport.add(oPdf)
formatExport.add(oSat)
formatExport.add(oExit)
oExt = InputListBox("SELECT", formatExport, formatExport(0), Title := "Title", ListName := "List")
If oExt = oExit Then Exit Sub
If oExt = oDxf Then 
	
	i = 0
	While i = 0 
	'Keep Selecting Faces, Hit Esc to finish
	L_oFace:
	oFace = ThisApplication.CommandManager.Pick(Inventor.SelectionFilterEnum.kPartFaceFilter, "Select face")
'	oFace = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAllPlanarEntities, "Pick a plane")
		If IsNothing (oFace) Then Goto L_oFace 
		i += 1
	End While
End If
Call ThisApplication.ActiveDocument.SelectSet.select(oface)
Dim oCmdMgr As CommandManager
oCmdMgr = ThisApplication.CommandManager


lfnSoueceDocWithoutExt = ThisDoc.FileName(False) 'without extension
ffnSourceDocWithExt = ThisDoc.PathAndFileName(False)

lfnSaveAsWithExt = lfnSoueceDocWithoutExt & oExt
ffnSaveAsWithExt = foderDxfSave & lfnSaveAsWithExt
Call oCmdMgr.ClearPrivateEvents()
Call oCmdMgr.PostPrivateEvent(PrivateEventTypeEnum.kFileNameEvent, ffnSaveAsWithExt)
Call oCmdMgr.ControlDefinitions.Item("GeomToDXFCommand").Execute
Call ThisApplication.ActiveDocument.SelectSet.clear()

 

0 Likes