EDA365电子工程师网

标题: skill loader请求支援 [打印本页]

作者: 1392431396    时间: 2016-12-4 22:40
标题: skill loader请求支援
; myExtractViews.il
; -- Displays a form with a selection list of
;  the available extract definition files
; -- Lets the user select any of the files on
;  the list as the “View file”
; -- Starts Allegro extract process with the
;  user-selected View file when
; the user picks Done from the form.
; Function to extract user selected view to the output file.
axlCmdRegister( "ext" 'myExtract)
(defun myExtractViews (viewFile outFile)
axlExtractToFile( viewFile outFile)
); defun myExtractViews
; Function to start the view extraction
(defun _extract ()
myExtractViews(
buildString(list(cadr(parseString(
axlGetVariable("TEXTPATH"))) selectedFile) "/")
"myextract.dat")
); defun _extract
; Form callback function to respond
(defun _formAction (form)
    (case form->curField
("done"
(axlFormClose form)
(axlCancelEnterFun)
(_extract)
(actionskill)

t)
("cancel"
(axlFormClose form)
(axlCancelEnterFun)
nil)
("view_file"
(if form->curValue
(progn
; Accept user input only if on list
if(member( form->curValue fileList)
then axlFormSetField( form
    "view_file" form->curValue)
else axlFormRestoreField(
form "view_file"))))
t)
("file_list"
(axlFormSetField form "view_file"
form->curValue)
selectedFile = form->curValue
t)); case
); defun _formAction
; User-callable function to set up and
;        display the Extract Selector form
(defun myExtract ()
fileList = (cdr (cdr (getDirFiles
cadr( parseString( axlGetVariable("TEXTPATH"))))))
form = axlFormCreate( (gensym)
"E:/Lenovo-F/Wakki/pcbenv/form/extract_selector.form" '("E" "OUTER")
'_formAction t)
axlFormTitle( form "Extract Selector")
axlFormSetField( form "view_file" (car fileList))
selectedFile = (car fileList)
foreach( fileName fileList
axlFormSetField( form "file_list" fileName))
axlFormDisplay( form)
); defun myExtract
(defun actionskill ()
  
  
  axlShellPost("echo skill action ok; mil2mm")
)


想做到的效果是:
选择列表里的skill,点击OK即可执行该skill命令。@deargds

作者: deargds    时间: 2016-12-5 08:31
缺FORM文件E:/Lenovo-F/Wakki/pcbenv/form/extract_selector.form  还有myextract.dat
作者: 1392431396    时间: 2016-12-5 11:01
deargds 发表于 2016-12-5 08:31
缺FORM文件E:/Lenovo-F/Wakki/pcbenv/form/extract_selector.form  还有myextract.dat

公司不给上传附件,我把Form内容贴上吧,(如下:)myextract.dat 是程式允许后产生的
FILE_TYPE=FORM_DEFN VERSION=2
FORM
FIXED
PORT 50 11
HEADER "Extract Selector"
TILE
TEXT "Select View File to Extract"
TLOC 12 1
ENDTEXT
TEXT "View File:"
TLOC 1 12
ENDTEXT
FIELD view_file
FLOC 12 12
STRFILLIN 24 24
ENDFIELD
FIELD file_list
FLOC 5 3
LIST "" 40 5
ENDFIELD
FIELD cancel
FLOC 5 15
MENUBUTTON "Cancel" 8 3
ENDFIELD
FIELD done
FLOC 15 15
MENUBUTTON "Done" 9 3
ENDFIELD
FIELD print
FLOC 25 15
MENUBUTTON "Print" 9 3
ENDFIELD
FIELD script
FLOC 35 15
MENUBUTTON "Script" 11 3
ENDFIELD
ENDTILE
ENDFORM

作者: deargds    时间: 2016-12-5 11:37
1392431396 发表于 2016-12-5 11:01
公司不给上传附件,我把Form内容贴上吧,(如下:)myextract.dat 是程式允许后产生的
FILE_TYPE=FORM_D ...

以下仅供参考
  1. ; myExtractViews.il
  2. ; -- Displays a form with a selection list of
  3. ;  the available extract definition files
  4. ; -- Lets the user select any of the files on
  5. ;  the list as the “View file”
  6. ; -- Starts Allegro extract process with the
  7. ;  user-selected View file when
  8. ; the user picks Done from the form.
  9. ; Function to extract user selected view to the output file.
  10. axlCmdRegister( "ext" 'myExtract)
  11. (defun myExtractViews (viewFile outFile)
  12. axlExtractToFile( viewFile outFile)
  13. ); defun myExtractViews
  14. ; Function to start the view extraction
  15. (defun _extract ()
  16. myExtractViews(strcat(axlGetVariable("allegro_install_dir") "/text/views/" selectedFile) "myextract.dat")
  17. ); defun _extract
  18. ; Form callback function to respond
  19. (defun _formAction (form)
  20.     (case form->curField
  21. ("done"
  22. (axlFormClose form)
  23. (axlCancelEnterFun)
  24. (_extract)
  25. (actionskill)

  26. t)
  27. ("cancel"
  28. (axlFormClose form)
  29. (axlCancelEnterFun)
  30. nil)
  31. ("view_file"
  32. (if form->curValue
  33. (progn
  34. ; Accept user input only if on list
  35. if(member( form->curValue fileList)
  36. then axlFormSetField( form
  37.     "view_file" form->curValue)
  38. else axlFormRestoreField(
  39. form "view_file"))))
  40. t)
  41. ("file_list"
  42. (axlFormSetField form "view_file"
  43. form->curValue)
  44. selectedFile = form->curValue
  45. t)); case
  46. ); defun _formAction
  47. ; User-callable function to set up and
  48. ;        display the Extract Selector form
  49. (defun myExtract ()
  50. fileList = setof(z getDirFiles(strcat(axlGetVariable("allegro_install_dir") "/text/views")) !member(z list("." "..")))
  51. form = axlFormCreate( (gensym)
  52. "extract_selector.form" '("E" "OUTER")
  53. '_formAction t)
  54. axlFormTitle( form "Extract Selector")
  55. axlFormSetField( form "view_file" (car fileList))
  56. selectedFile = (car fileList)
  57. foreach( fileName fileList
  58. axlFormSetField( form "file_list" fileName))
  59. axlFormDisplay( form)
  60. ); defun myExtract
  61. (defun actionskill ()
  62.   
  63.   
  64.   axlShellPost("echo skill action ok; mil2mm")
  65. )
复制代码




作者: 1392431396    时间: 2016-12-5 12:16
deargds 发表于 2016-12-5 11:37
以下仅供参考

deargds, 能不能把选中的文件名**(不包括.il后缀)作为变量放到以下函数中粉红色高亮的地方去,做命令使用:

(defun actionskill ()
  
  
  axlShellPost("echo skill action ok; mil2mm")
)

当点中filelist中的文件,再点击OK即可运行被选中的skill

作者: deargds    时间: 2016-12-5 13:06
1392431396 发表于 2016-12-5 12:16
deargds, 能不能把选中的文件名**(不包括.il后缀)作为变量放到以下函数中粉红色高亮的地方去,做命令使用 ...
  1. (defun actionskill ()
  2.   axlShellPost(sprintf(nil "echo skill action ok; %s" cadr(axlDMFileParts(selectedFile))))
  3. )
复制代码



作者: 1392431396    时间: 2016-12-5 14:38
deargds 发表于 2016-12-5 13:06

真厉害,deargds!  能执行相应skill了;  还有里面的filelist参数怎么指定到自定义的skill文件路径
fileList = setof(z getDirFiles(strcat(axlGetVariable("allegro_install_dir") "/text/views")) !member(z list("." "..")))
现在是allegro 里面的"text” 路径,这样不怎么理想



作者: wcjcn    时间: 2017-6-9 09:19
学习了。。。。。。。
作者: 渐行渐远渐无书    时间: 2017-6-9 10:25
这么复杂。。




欢迎光临 EDA365电子工程师网 (https://bbs.elecnest.cn/) Powered by Discuz! X3.2