乐筑天下

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

[编程交流] Restore Osnap's

[复制链接]

6

主题

14

帖子

8

银币

初来乍到

Rank: 1

铜币
30
发表于 2022-7-6 17:49:25 | 显示全部楼层
 
Perfect!  Thanks to everyone that helped me on this one!
回复

使用道具 举报

0

主题

5

帖子

5

银币

初来乍到

Rank: 1

铜币
0
发表于 2022-7-6 17:51:08 | 显示全部楼层
I found this to work for getting you preset osnap variables and restoring them back after the program is finished.
 
Put this first inside the lisp program
  (setq osn (getvar "osmode"))
 
Put this last inside the lisp program
  (command "osmode" osn)
回复

使用道具 举报

2

主题

11

帖子

9

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-6 17:53:40 | 显示全部楼层
 
In writing various LISP routines I always want to turn the Osnaps off and then reset them to whatever the user had them set at previously. To capture the initial settings I use something like:
 
(setq old_mode (getvar "osmode") )
(setvar "osmode" 0)
 
This captures the current setting into the variable old_mode and then turns all of the Osnap settings off.
 
To return to the initial Osnap state I would use:
 
(setvar "osmode" old_mode)
回复

使用道具 举报

0

主题

5

帖子

5

银币

初来乍到

Rank: 1

铜币
0
发表于 2022-7-6 17:58:30 | 显示全部楼层
Yeah, I do too. I was just copying a piece of code as an option to the original question. Here's what I pasted from:
 
(defun c:2at ()
        (defun dtr (a)
        (* pi(/ a 180.0))
        )
  (command "layer" "S" "fan" "")
  (command "orthomode" "1")
  (setq osn (getvar "osmode"))
  (command "osnap" "center")
  (setq pick (getpoint "\Select isolator hole on base: "))
  (setq rot1 (polar pick (dtr 0.0) 0.6))
  (command "osmode" "0")
  (command "insert" "2a-isolatortop=" pick "" "" "")
  (command "insert" "2a-isoplatetop=" pick "" "" "")
  (command "rotate" "c" pick rot1 "l" "" pick pause)
  (command "osmode" osn)
  (command "layer" "S" "casing" ""))
 
It's an isolator top view that places them on A/C fans.
回复

使用道具 举报

54

主题

3755

帖子

3583

银币

后起之秀

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

铜币
438
发表于 2022-7-6 18:01:11 | 显示全部楼层
i use this:
  1. (defun c:AS ( / )(setvar 'osmode 105)(princ "\nActive Osnaps: End, Insertion, Intersection, & Node")(princ));defun
i can run it real quick to set my desired snaps, or i can run it transparently (typing: 'as)
回复

使用道具 举报

0

主题

5

帖子

5

银币

初来乍到

Rank: 1

铜币
0
发表于 2022-7-6 18:03:53 | 显示全部楼层
Good idea for a stand alone machine.

The only problem I can see with setting a specific snap, is in the case of sharing a server with AutoCAD & the programs. Each individual person, as you probably already know, have their own settings and style they prefer. The getvar osmode grabs each persons settings and holds on to it until it completes the function of the program, then resetting it back to each individual persons settings with the "osmode" re-call.
回复

使用道具 举报

10

主题

16

帖子

6

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
50
发表于 2022-7-6 18:08:03 | 显示全部楼层
 
That is my problem; we have a command (which i cannot edit) which sets my OSnap settings to Nearest. I edited my CUI file so that Shift + Button 3 will set my Osnap to 4263. The problem is that I want to do this whilst the "faulty" command is running, not after. Thanks.
 
Hello everyone BTW
回复

使用道具 举报

1

主题

61

帖子

65

银币

初来乍到

Rank: 1

铜币
4
发表于 2022-7-6 18:09:43 | 显示全部楼层
 
yawdapaah, the string (setvar "osmode" 4263)(princ) will set the osnaps while in a command,  you can make a tollbar button to reset the settings while in a command, or a keyboard shortcut
回复

使用道具 举报

0

主题

5

帖子

5

银币

初来乍到

Rank: 1

铜币
0
发表于 2022-7-6 18:14:49 | 显示全部楼层
yawdapaah,
How is this command or program that your talking about, initiated? From a Toolbar button located in the CUI? Shortcut keys? Command prompt from your appload? Just curious..........
回复

使用道具 举报

0

主题

5

帖子

5

银币

初来乍到

Rank: 1

铜币
0
发表于 2022-7-6 18:18:11 | 显示全部楼层
Also something to think about: What is the first command you use right after this program has ran it's course.
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-4 16:45 , Processed in 0.660560 second(s), 70 queries .

© 2020-2025 乐筑天下

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