cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Creo Distributed Batch to run a Mapkey to export dxf from a drawing that has 10 or more pages

Psionic
5-Regular Member

Creo Distributed Batch to run a Mapkey to export dxf from a drawing that has 10 or more pages

Hello,

Creo Parametric 8.0.6

 

I've created a mapkey to export dxf file and save drawing/part parameters then use vbscript to rename the dxf file, the mapkey works great in Creo but when i use distrubuted batch to export dxf using this mapkey it will only export the first page, is there a way to loop this for all pages in a drawing?

 

Thanks,

TTD 

<TTD version="1.0" created_by="PTC">
<DESCRIPTION>Run a mapkey defined in a config.pro</DESCRIPTION>
<GROUP>Misc</GROUP>
<DETAILS>Will be run on any file type; user is responsible for choosing types that mapkey will operate on correctly.</DETAILS>
<SERVICE name="dbatchs"/>
<FILTER_FILE_TYPES type=".drw"/>
<!-- Replace "F1" with chosen mapkey when customizing file -->
<TKFUNC func="ProMapkeyRun" mapkey_key_sequence="dxfdet">
<save_model>false</save_model>
</TKFUNC>
</TTD>

4 REPLIES 4
Chris3
21-Topaz I
(To:Psionic)

When you say it works great in Creo does it work for all pages?

 

Can you post the mapkey so we can look at what you are doing?

 

In drawing mode there is a go to sheet command. They removed it from the ribbon a while back but you can still find it in the search.

Screenshot 2024-09-11 130510.png

If the problem is advancing to the next page you could use this, although would have to test out what happens if you try and go to page 2 on a drawing that only has 1 sheet. It may cause Creo to crash. The only place I use this with mapkeys is to go to the first page so I don't know what happens if you try and go to a sheet that doesn't exist.

Psionic
5-Regular Member
(To:Chris3)

this is the mapkey i use in distribute batch, this mapkey also calls for another mapkey and also run a vbscript

 

mapkey dxfdet @MAPKEY_NAMEDXF Detail Number;@MAPKEY_LABELDXF Detail Number;\
mapkey(continued) ~ Close `main_dlg_cur` `appl_casc`;~ Command `ProCmdExportPreview` ;\
mapkey(continued) ~ Command `ProCmdDwgPubSetDeliverable` `DXF`;\
mapkey(continued) ~ Command `ProCmdDwgPubSettings` ;\
mapkey(continued) ~ Select `export_2d_dlg` `Splines_Group` 1 `as_splines`;\
mapkey(continued) ~ Select `export_2d_dlg` `Hatching_Group` 1 `as_hatch`;\
mapkey(continued) ~ Select `export_2d_dlg` `Points_Group` 1 `as_points`;\
mapkey(continued) ~ Select `export_2d_dlg` `Notes_Group` 1 `as_notes`;\
mapkey(continued) ~ Activate `export_2d_dlg` `GenLog_Button` 0;\
mapkey(continued) ~ Activate `export_2d_dlg` `OK_Button`;~ Command `ProCmdDwgPubExport` ;\
mapkey(continued) ~ LButtonArm `file_saveas` `tb_EMBED_BROWSER_TB_SAB_LAYOUT` 3 567 12 0;\
mapkey(continued) ~ LButtonDisarm `file_saveas` `tb_EMBED_BROWSER_TB_SAB_LAYOUT` 3 567 12 0;\
mapkey(continued) ~ LButtonActivate `file_saveas` `tb_EMBED_BROWSER_TB_SAB_LAYOUT` 3 567 12 0;\
mapkey(continued) ~ Input `file_saveas` `opt_EMBED_BROWSER_TB_SAB_LAYOUT` \
mapkey(continued) `F:\\dxf_pdf_export\\temp_workspace`;\
mapkey(continued) ~ Update `file_saveas` `opt_EMBED_BROWSER_TB_SAB_LAYOUT` \
mapkey(continued) `F:\\dxf_pdf_export\\temp_workspace`;\
mapkey(continued) ~ Activate `file_saveas` `opt_EMBED_BROWSER_TB_SAB_LAYOUT`;\
mapkey(continued) ~ Activate `file_saveas` `OK`;~ Command `ProCmdDwgPubCloseExportPvw` ;\
mapkey(continued) ~ Activate `main_dlg_cur` `ProCmdWinActivate.view`;%dwgpara;\
mapkey(continued) #sheets;#next;#done/return;\
mapkey(continued) @SYSTEMstart F:\\dxf_pdf_export\\temp_workspace\\rename.vbs;

 

mapkey dwgpara @MAPKEY_NAMESave dwg parameters;@MAPKEY_LABELSave dwg parameters;\
mapkey(continued) ~ Activate `main_dlg_cur` `page_Annotate_control_btn` 1;\
mapkey(continued) ~ Command `ProCmdDtlInsFreeNote` ;\
mapkey(continued) ~ Select `dwg_selpnt_dlg` `rad_sel_method` 1 `abs_coord`;\
mapkey(continued) ~ Input `dwg_selpnt_dlg` `opt_abs_x` `-`;\
mapkey(continued) ~ Input `dwg_selpnt_dlg` `opt_abs_x` `-2`;\
mapkey(continued) ~ Update `dwg_selpnt_dlg` `opt_abs_x` `-2`;\
mapkey(continued) ~ FocusOut `dwg_selpnt_dlg` `opt_abs_x`;\
mapkey(continued) ~ Input `dwg_selpnt_dlg` `opt_abs_y` `5`;\
mapkey(continued) ~ Update `dwg_selpnt_dlg` `opt_abs_y` `5`;\
mapkey(continued) ~ FocusOut `dwg_selpnt_dlg` `opt_abs_y`;~ Activate `dwg_selpnt_dlg` `psh_ok`;\
mapkey(continued) ~ Command `ProCmdDtlTextFromFile` ;\
mapkey(continued) ~ Trail `UI Desktop` `UI Desktop` `DLG_PREVIEW_POST` `file_open`;\
mapkey(continued) ~ Trail `UI Desktop` `UI Desktop` `PREVIEW_POPUP_TIMER` \
mapkey(continued) `file_open:Ph_list.Filelist:<NULL>`;\
mapkey(continued) ~ Select `file_open` `Ph_list.Filelist` 1 `dwg_para.txt`;\
mapkey(continued) ~ Activate `file_open` `Ph_list.Filelist` 1 `dwg_para.txt`;\
mapkey(continued) ~ Command `ProCmdDtlTextSaveToFile` ;\
mapkey(continued) ~ Trail `UI Desktop` `UI Desktop` `DLG_PREVIEW_POST` `file_open`;\
mapkey(continued) ~ Select `file_open` `Location Browser`;\
mapkey(continued) ~ Close `file_open` `Location Browser`;\
mapkey(continued) ~ Activate `file_open` `M_pfafs:drives`;\
mapkey(continued) ~ Select `file_open` `Ph_list.Filelist` 1 `f:`;\
mapkey(continued) ~ Activate `file_open` `Ph_list.Filelist` 1 `f:`;\
mapkey(continued) ~ Select `file_open` `Ph_list.Filelist` 1 `dxf_pdf_export`;\
mapkey(continued) ~ Activate `file_open` `Ph_list.Filelist` 1 `dxf_pdf_export`;\
mapkey(continued) ~ Select `file_open` `Ph_list.Filelist` 1 `temp_workspace`;\
mapkey(continued) ~ Activate `file_open` `Ph_list.Filelist` 1 `temp_workspace`;\
mapkey(continued) ~ Input `file_open` `Inputname` `dwgpara.txt`;\
mapkey(continued) ~ Update `file_open` `Inputname` `dwgpara.txt`;\
mapkey(continued) ~ Command `ProFileSelPushOpen@context_dlg_open_cmd` ;\
mapkey(continued) ~ Key `main_dlg_cur` `proe_win` 9 1336 1123 196608 512 3401 1746 3840 2160 \
mapkey(continued) 5348506 `Del`;~ Command `ProCmdEditDelete` ;\
mapkey(continued) ~ Activate `main_dlg_cur` `page_Layout_control_btn` 1;

 

rename.vbs

Dim fso, file, detail, currentsheet, modeltype, dwgname, WshShell
Set fso = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("WScript.Shell")
 
' Set temporary workspace folder
workspacePath = "F:\dxf_pdf_export\temp_workspace"
 
' Set DXF folder
dxfPath = "F:\dxf_pdf_export\dxf"
 
' Set PDF folder
pdfPath = "F:\dxf_pdf_export\pdf"
 
' Initialize variables
detail = ""
currentsheet = ""
dwgname = ""
modeltype = ""
 
' Read from dwgpara.txt file
Set ts = fso.OpenTextFile(workspacePath & "\dwgpara.txt", 1)
Do Until ts.AtEndOfStream
    line = ts.ReadLine
    If InStr(LCase(line), "modeltype") > 0 Then
        modeltype = Split(LCase(line), " ")(1)
    ElseIf InStr(LCase(line), "detail") > 0 Then
        detail = Split(LCase(line), " ")(1)
        If detail = "detail[.0]" And modeltype = "assem" Then
            detail = "sub_assembly"
        ElseIf detail = "detail[.0]" And modeltype = "part" Then
            detail = "NA"
        End If
    ElseIf InStr(LCase(line), "currentsheet") > 0 Then
        currentsheet = Split(LCase(line), " ")(1)
    ElseIf InStr(LCase(line), "dwgname") > 0 Then
        dwgname = Split(LCase(line), " ")(1)
    End If
Loop
ts.Close
 
' Rename and move files
For Each file In fso.GetFolder(workspacePath).Files
    If LCase(fso.GetExtensionName(file.Name)) = "pdf" Then
        ' Construct the new file name
        If detail = "sub_assembly" Then
            newFileName = dwgname & "_sheet-" & currentsheet & "_" & detail & ".pdf"
        Else
            newFileName = dwgname & "_sheet-" & currentsheet & "_det-" & detail & ".pdf"
        End If
              
        ' Rename the corresponding .pdf file
        pdfFilePath = fso.BuildPath(workspacePath, file.Name)
fso.MoveFile pdfFilePath, fso.BuildPath(pdfPath, newFileName)
 
    ElseIf LCase(fso.GetExtensionName(file.Name)) = "dxf" Then
        ' Construct the new file name
        If detail = "sub_assembly" Then
            newFileName = dwgname & "_sheet-" & currentsheet & "_" & detail & ".dxf"
        Else
            newFileName = dwgname & "_sheet-" & currentsheet & "_det-" & detail & ".dxf"
        End If
              
        ' Rename the corresponding .dxf file
        dxfFilePath = fso.BuildPath(workspacePath, file.Name)
fso.MoveFile dxfFilePath, fso.BuildPath(dxfPath, newFileName)
 
    End If
Next
 
' Delete text and log files
For Each file In fso.GetFolder(workspacePath).Files
    If LCase(fso.GetExtensionName(file.Name)) = "txt" Or LCase(fso.GetExtensionName(file.Name)) = "log" Then
        file.Delete
    End If
Next

 

Chris3
21-Topaz I
(To:Psionic)

ok it doesn't look like you are changing sheets then. So try adding in the bit where you change sheets. If Creo crashes when you try and change to sheet 2 if it doesn't exist then it looks like you are exporting the parameters so you could use those to have VBS create a mapkey that iterates to through the number of sheets you have. Then you would import that mapkey (generated by vbs) and run that.

Psionic
5-Regular Member
(To:Chris3)

My mapkeys and script work fine but distributed batch doesn't loop the mapkey base on # of pages in the drawing.  I wonder if there's a way to add this mapkey within 2d_dxf_export function.

 

a workaround is to chain the TKFUNC

 

<TTD version="1.0" created_by="PTC">
<DESCRIPTION>Run "DXFDET" mapkey defined in a config.pro</DESCRIPTION>
<GROUP>Misc</GROUP>
<DETAILS>Will be run on any file type; user is responsible for choosing types that mapkey will operate on correctly.</DETAILS>
<SERVICE name="dbatchs"/>
<FILTER_FILE_TYPES type=".drw"/>
<!-- Replace "F1" with chosen mapkey when customizing file -->
<TKFUNC func="ProMapkeyRun" mapkey_key_sequence="dxfdet"></TKFUNC>
<TKFUNC func="ProMapkeyRun" mapkey_key_sequence="dxfdet"></TKFUNC>
<TKFUNC func="ProMapkeyRun" mapkey_key_sequence="dxfdet"></TKFUNC>
<TKFUNC func="ProMapkeyRun" mapkey_key_sequence="dxfdet"></TKFUNC>
<TKFUNC func="ProMapkeyRun" mapkey_key_sequence="dxfdet"></TKFUNC>
<TKFUNC func="ProMapkeyRun" mapkey_key_sequence="dxfdet"></TKFUNC>
<TKFUNC func="ProMapkeyRun" mapkey_key_sequence="dxfdet"></TKFUNC>
<TKFUNC func="ProMapkeyRun" mapkey_key_sequence="dxfdet"></TKFUNC>
<TKFUNC func="ProMapkeyRun" mapkey_key_sequence="dxfdet"></TKFUNC>
<TKFUNC func="ProMapkeyRun" mapkey_key_sequence="dxfdet"></TKFUNC>
<TKFUNC func="ProMapkeyRun" mapkey_key_sequence="dxfdet"></TKFUNC>
<TKFUNC func="ProMapkeyRun" mapkey_key_sequence="dxfdet"></TKFUNC>
<TKFUNC func="ProMapkeyRun" mapkey_key_sequence="dxfdet"></TKFUNC>
<TKFUNC func="ProMapkeyRun" mapkey_key_sequence="dxfdet"></TKFUNC>
<TKFUNC func="ProMapkeyRun" mapkey_key_sequence="dxfdet"></TKFUNC>
<TKFUNC func="ProMapkeyRun" mapkey_key_sequence="dxfdet"></TKFUNC>
<TKFUNC func="ProMapkeyRun" mapkey_key_sequence="dxfdet"></TKFUNC>
<TKFUNC func="ProMapkeyRun" mapkey_key_sequence="dxfdet"></TKFUNC>
<TKFUNC func="ProMapkeyRun" mapkey_key_sequence="dxfdet"></TKFUNC>
<TKFUNC func="ProMapkeyRun" mapkey_key_sequence="dxfdet"></TKFUNC>
</TTD>

Announcements
NEW Creo+ Topics: Real-time Collaboration


Top Tags