乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 40|回复: 9

[编程交流] 'Put' pc3 file to al

[复制链接]

55

主题

243

帖子

188

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
275
发表于 2022-7-6 11:03:02 | 显示全部楼层 |阅读模式
Almost there with what I am trying to achieve.
I would like to assign all layout tabs with the same pc3 picked by the user. How would that be done? Is there a function floating around that does that?
thanks for any help!
 
note: using a Dos_Lib function
 
  1. ;some parts by Lee Mac (defun C:SetPC3 (/ doc Pc3Files pc3) (vl-load-com) (vla-RefreshPlotDeviceInfo   (vla-get-ActiveLayout     (setq doc     (vla-get-activedocument       (vlax-get-acad-object))))) (setq Pc3Files (vl-remove-if-not    (function      (lambda (x) (wcmatch x "*.pc3")))    (vlax-invoke      (vla-item (vla-get-layouts doc) "Model")      'GetPlotDeviceNames))) (setq pc3 (dos_listbox      "Assign pc3 file to all tabs"      "Select a pc3 file to assign  to all tab layouts"      Pc3Files  ""  )) (foreach x     (vl-remove "Model" (layoutlist))   (putPc3 x Pc3Files);do I need a function - putPc3         ;or a few lines of extra code? );foreach );defun
回复

使用道具 举报

54

主题

3755

帖子

3583

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
438
发表于 2022-7-6 11:11:18 | 显示全部楼层
  1.   (vlax-for x (vla-get-layouts doc)   (or (eq (vla-get-name x) "Model")       (vl-catch-all-apply (function vla-put-configname) (list x pc3))   ) )
However, your code could use a little house cleaning (since it will call the layouts multiple times, etc.).
 
For the record (layoutlist) does not include "Model".
回复

使用道具 举报

55

主题

243

帖子

188

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
275
发表于 2022-7-6 11:19:33 | 显示全部楼层
thanks Alan
but I am not sure whether I should make it a function or where to add it to my above code?
 
and yes you are correct re:  (layoutlist) does not include "Model".
回复

使用道具 举报

54

主题

3755

帖子

3583

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
438
发表于 2022-7-6 11:28:18 | 显示全部楼层
Remove all that foreach crap at the bottom and add (if (setq pc3.....) add what I posted here )
 
 
  1. (if (setq pc3 (dos_listbox               "Assign pc3 file to all tabs"               "Select a pc3 file to assign  to all tab layouts"               Pc3Files               ""             )   ) (vlax-for x (vla-get-layouts doc)   (or (eq (vla-get-name x) "Model")       (vl-catch-all-apply (function vla-put-configname) (list x pc3))   ) ))
回复

使用道具 举报

55

主题

243

帖子

188

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
275
发表于 2022-7-6 11:35:19 | 显示全部楼层
thanks Alan - but I can not get it to work with what you suggested
回复

使用道具 举报

54

主题

3755

帖子

3583

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
438
发表于 2022-7-6 11:38:01 | 显示全部楼层
  1. ;some parts by Lee Mac (defun C:SetPC3 (/ doc Pc3Files pc3) (vl-load-com) (vla-RefreshPlotDeviceInfo   (vla-get-ActiveLayout     (setq doc            (vla-get-activedocument              (vlax-get-acad-object)            )     )   ) ) (if (and (setq Pc3Files (vl-remove-if-not                           (function                             (lambda (x) (wcmatch x "*.pc3"))                           )                           (vlax-invoke                             (vla-item (vla-get-layouts doc) "Model")                             'GetPlotDeviceNames                           )                         )          )          (setq pc3 (dos_listbox                      "Assign pc3 file to all tabs"                      "Select a pc3 file to assign  to all tab layouts"                      Pc3Files                      ""                    )          )     )   (vlax-for x (vla-get-layouts doc)     (or (eq (vla-get-name x) "Model")         (vl-catch-all-apply (function vla-put-configname) (list x pc3))     )   ) ) (princ)) ;defun
回复

使用道具 举报

54

主题

3755

帖子

3583

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
438
发表于 2022-7-6 11:49:15 | 显示全部楼层
I'm not sure why you are refreshing the plotter devices to the active layout, but 'get'ing the plotter devices from model. What if you are not in model. Why not just take them from the active layout that you've already defined?
回复

使用道具 举报

55

主题

243

帖子

188

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
275
发表于 2022-7-6 11:51:42 | 显示全部楼层
Hey Alan that works brilliant - and I learned something new
 
I suppose you meant :
  1.               (vlax-for x (vla-get-layouts doc)should be: (vlax-for x (vla-get-layouts *AcadDoc )
just testing me I guess?:wink:
 
cheers SF
回复

使用道具 举报

54

主题

3755

帖子

3583

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
438
发表于 2022-7-6 12:01:07 | 显示全部楼层
Huh? At the beginning of the routine, you defined the active document as doc.Am I missing something?
回复

使用道具 举报

54

主题

3755

帖子

3583

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
438
发表于 2022-7-6 12:08:24 | 显示全部楼层
Keep in mind that, while you've successfully assigned a plotter to each layout, nothing else is set properly (sheet size, ctb, etc.). You should really look into using PageSetups. This will avoid a lot of legwork.
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-6 11:15 , Processed in 1.069198 second(s), 72 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表