乐筑天下

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

[编程交流] need help shortening my '

[复制链接]

23

主题

117

帖子

87

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
123
发表于 2022-7-6 10:20:39 | 显示全部楼层
This is what I like to see, different techniques to accomplish the same result. It opens the mind.
 
 
Basicaly
if one layer is in both states (frozen) and (locked), lets say layer 0 is Frozen and Locked, the list "lst" will contain layer "0" twice, one instance being frozen, and one instance being locked.
 
so as "lst" is being passed to the (foreach)function, Layer 0 will pass thru the (foreach) function twice, once to restore the frozen layer and once to restore the locked layer.
 
Is this correct??? (fingers crossed, that I am right)
 
 
Thanks Alan
回复

使用道具 举报

23

主题

117

帖子

87

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
123
发表于 2022-7-6 10:23:31 | 显示全部楼层
 
Alan
(setq lst (cons (list x 'Freeze :vlax-true) lst))
How does (lst) get the property (‘Freeze) from (x) as each layer passes thru (x) without the (vlax-get-property) function?
回复

使用道具 举报

23

主题

117

帖子

87

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
123
发表于 2022-7-6 10:26:16 | 显示全部楼层
Alan
 
Sorry for the bother but I really do want to understand my question above.
 
Thanks
回复

使用道具 举报

54

主题

3755

帖子

3583

银币

后起之秀

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

铜币
438
发表于 2022-7-6 10:29:20 | 显示全部楼层
I freeze the layer in the next line of code. The lst variable is just so I can later apply vlax-put-property to each sublist. 
eg.
  1. (foreach x lst (apply (function vlax-put-property) x))
回复

使用道具 举报

23

主题

117

帖子

87

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
123
发表于 2022-7-6 10:32:14 | 显示全部楼层
Thanks for the reply Alan
 
Sorry, I don't think I am asking my question correctly.
 
 
  1. (setq lst (cons (list x 'Lock :vlax-true) lst))
 
Where did 'Lock come from?  or
 
  1. (setq lst (cons (list x 'Freeze :vlax-true) lst))
 
Where did "Freeze come from?
 
It looks to me you are making a list using some sort of get property technique.
 
  1. (setq lst (vlax-get-property Freeze 'ActiveLayer))
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 10:37:43 | 显示全部楼层
'Lock and 'Freeze are symbol arguments for the vlax-put-property function (hence why they are quoted).
 
Alan could have alternatively used:
 
  1. (setq lst (cons (list x "Lock" :vlax-true) lst))
Following the vlax-for loop through the layer collection, the list 'lst' might look something like:
 
  1. ((# 'Lock :vlax-true) ... )
# being a VLA Layer Object. Each sublist is a list of arguments for the vlax-put-property function.
 
Then, in the foreach loop at the end of the program, these sublists are supplied as arguments to the apply function:
 
  1. (apply 'vlax-put-property '( 'Lock :vlax-true))
Which is equivalent to:
 
  1. (vlax-put-property  'Lock :vlax-true)
回复

使用道具 举报

54

主题

3755

帖子

3583

银币

后起之秀

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

铜币
438
发表于 2022-7-6 10:39:11 | 显示全部楼层
LoL
Well, there you go.
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 10:43:34 | 显示全部楼层
Sorry for jumping in Alan
回复

使用道具 举报

54

主题

3755

帖子

3583

银币

后起之秀

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

铜币
438
发表于 2022-7-6 10:44:45 | 显示全部楼层
Oh, no worries. I was just laughing at it. Step in an explain my work anytime.
回复

使用道具 举报

23

主题

117

帖子

87

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
123
发表于 2022-7-6 10:48:27 | 显示全部楼层
I think I understand.
 
  1. (vlax-for x (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))    [color=red];this gets me to the layer properties[/color]
 
 
  1. (and (eq (vla-get-lock x) :vlax-true)    [color=red];this get me the lock variable [/color]
 
 
  1. (setq lst (cons (list x 'Lock :vlax-true) lst))     [color=red];this creates the list of locked layers[/color]
 
  1. (vla-put-freeze x :vlax-false)    [color=red] ;goes thru the vlax-for turning all frozen layers to thawed[/color]
 
 
So, I am going to ask a silly question, 'Freeze and 'Lock are the properties of Layer, 'Freeze and 'Lock are arguments not symbols so I could not use any arbitrary word such as 'Snow, for example.
 
 
 
Why are they quoted? I have been wondering how and when to know to use 'quote and what do they mean. I have seen it in (mapcar) and (lambda)
 
from help menu:
 
  1. (mapcar  '(lambda (x)          (+ x 3)          )          '(10 20 30))
 
 
'quoted lists and 'quoted function and 'quoted arguments (this I don't understand)
 
 
Anyway guys, thanks for the education
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-7 00:13 , Processed in 1.959764 second(s), 70 queries .

© 2020-2025 乐筑天下

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