乐筑天下

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

[编程交流] Can't pass variable to De

[复制链接]

12

主题

28

帖子

21

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
65
发表于 2022-7-6 17:19:27 | 显示全部楼层 |阅读模式
In code i have this line
  1. ThisDrawing.Layers(Variable1).Delete
When i point mouse on Varibale1 pops out text:
I'm trying to delete this layer PH-15A.. What is wrong here?
回复

使用道具 举报

2

主题

439

帖子

536

银币

限制会员

铜币
-14
发表于 2022-7-6 17:35:45 | 显示全部楼层
All good. But you need to delete (or change layer) all entities on this layer include block definitions, block references and multiline styles.
回复

使用道具 举报

12

主题

28

帖子

21

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
65
发表于 2022-7-6 17:43:57 | 显示全部楼层
There was objects in this layer.. but i have deleted them..
When i make an empty layer Layer1 and in the code change the line to
  1. ThisDrawing.Layers("Layer1").Delete
then it is deleted, but when i change to the other layer, where objects was, then error apears
Is there a way i can tell the code to delete layer anyway?
 
EDIT: I'm still testing, i guess i didn't delete all..
回复

使用道具 举报

12

主题

28

帖子

21

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
65
发表于 2022-7-6 17:54:02 | 显示全部楼层
I have two dvb files under DOCS, and I have opened Visual Basic window but cant find icon where to open these files where new code is?
回复

使用道具 举报

12

主题

28

帖子

21

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
65
发表于 2022-7-6 18:01:17 | 显示全部楼层
I really don't understand. By help of other member i have this code
  1. Sub LayDel() 'Uses The GetLispSym Function Dim Variable1 As String 'Variable1 = GetLispSym("LAYDEL-NAME") 'At the command line, set your variable (setq LAYDEL-NAME "Layer1") ThisDrawing.Layers("Layer1").DeleteEnd Sub
 
After command "solprof" I have these layer PH-.. and PV-..
I cant delete them even everything is deleted. Even after ctr+A and DELETE..
回复

使用道具 举报

0

主题

1

帖子

1

银币

初来乍到

Rank: 1

铜币
0
发表于 2022-7-6 18:11:27 | 显示全部楼层
Since the layers won't can't be deleted you can use the layer merge command to move them over to the new layer. That would effectively "delete" the layers from the drawings ... I used the layer merge in the following manner:
 
'Create New Viewport
strMView = "mview" & vbLf & "f" & vbLf
ThisDrawing.SendCommand strMView
 
'Use AutoLISP to pass value to VBA (Viewport Name)
strVPLisp = "(setvar " + Chr$(34) + "USERS1" + Chr$(34) + " (cdr (assoc 5 (entget (entlast)))))" + vbCr
ThisDrawing.SendCommand strVPLisp
strVPName = ThisDrawing.GetVariable("USERS1")
 
'Set Name of Layer to be merged
strVPHidden = "PH-" & strVPName
strLayerMergeH = "-laymrg" & vbLf & "n" & vbLf & strVPHidden & vbLf & vbLf & "n" & vbLf & "MergedToLayerName" & vbLf & "y" & vbLf
 
'Merge layer
ThisDrawing.SendCommand strLayerMergeH
 
** I want to make sure everyone knows that I typically program in lisp and, this piece of code was just recently modified from something I made while I was in school in 2002. I haven't programmed in VBA since that time, prior to the recent modification, and I'm sure that some of the commands could be done without using the "SendCommand" feature.
 
I believe I cherry picked all the code and for what it's worth I hope that this might give you some ideas on how to fix your issue.
 
Rob
回复

使用道具 举报

12

主题

28

帖子

21

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
65
发表于 2022-7-6 18:21:17 | 显示全部楼层
Thank you.. I'll take a look..
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-4 16:23 , Processed in 0.362088 second(s), 66 queries .

© 2020-2025 乐筑天下

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