乐筑天下

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

[编程交流] VBA - Dimension Styles

[复制链接]

21

主题

146

帖子

127

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
106
发表于 2022-7-6 17:16:41 | 显示全部楼层 |阅读模式
Another question from me  
 
Having created a dimesnion style I want to try and set all of its values. e.g linetype bylayer. However I just can't find the information in the provided help file.
 
thanks in advance
回复

使用道具 举报

2

主题

439

帖子

536

银币

限制会员

铜币
-14
发表于 2022-7-6 17:29:14 | 显示全部楼层
1. You should draw some dimension (for ex. DIMLINEAR) and set all properties you need for this single dimension.
 
2. Add a new DimensionStyle to the DimensionStyles collection.
 
3. Use method CopyFrom for copy properties from the sample dimension to the DimensionStyle.
 
Current dimension style is only set of system variables which controls new dimensions properties.
回复

使用道具 举报

NBC

4

主题

182

帖子

178

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-6 17:34:51 | 显示全部楼层
Use a similar syntax as listed below:
  1. ThisDrawing.SetVariable SysvarName, sysVarData
 
where:
SysvarName is the name of the variable you wish to set
sysVarData is the value of the variable
回复

使用道具 举报

21

主题

146

帖子

127

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
106
发表于 2022-7-6 17:46:34 | 显示全部楼层
Excellent, thanks I'll try these when I get to work on Monday
回复

使用道具 举报

21

主题

146

帖子

127

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
106
发表于 2022-7-6 17:52:12 | 显示全部楼层
What I am trying to achiecve is the succesful creation of a new dimesnion style which will have values defined in my VBA macro for:
 
- colour
- Dim Lines Linetype
- Dim Lines Lineweight
- Ext line 1
- Ext Line 2
- Ext Line lineweight
- Extend Beyond Dim lines
- Offset from Origin
 
Still having some difficulty with this.
回复

使用道具 举报

NBC

4

主题

182

帖子

178

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-6 18:01:42 | 显示全部楼层
If you already have your required Dimension Style setup in a drawing; type in _.sysvdlg at the command line.  This will bring up a box with all your system variables in it.
Now the fun bit to filter everything else out, apart from all the variables associated with dimensioning.
In the top box on the left hand side; and before the * type in dim.
Then hit the Save Filtered button; name your file according to something like dim_variables.svf
Using Windows Explorer locate the file you just saved.
Right click on it, and choose Open With.
Try to select Notepad, or some other equivalent editing program.
In the file that is opened you should now see all the variables that are associated with the dimension style.
It should now be a simple process to incorporate all those settings into the sample code I posted earlier in this thread.
回复

使用道具 举报

2

主题

439

帖子

536

银币

限制会员

铜币
-14
发表于 2022-7-6 18:07:39 | 显示全部楼层
 
Look for my post #2 and this simplified example. It will draw sample aligned dimension in your drawing, creates "Wannabe_DimStyle" dimension style and copy proprties from sample dimension to your dimension style:
 
  1. Sub CreationDimStyle()Dim mSp As AcadModelSpaceDim sDim As AcadDimAlignedDim pt1(0 To 2) As DoubleDim pt2(0 To 2) As DoubleDim tPos(0 To 2) As DoubleDim dCol As AcadDimStylesDim nDim As AcadDimStyle' Set poits to draw dimensionpt1(0) = 0#: pt1(1) = 0#: pt1(2) = 0#pt2(0) = 0#: pt2(1) = 100#: pt2(2) = 0#tPos(0) = 50#: tPos(1) = 15#: tPos(2) = 0#'Get Model Space CollectionSet mSp = ThisDrawing.ModelSpace' Add new sample aligned dimensionSet sDim = mSp.AddDimAligned(pt1, pt2, tPos)[color="Blue"]' Set some dimension properties[/color]sDim.color = 1sDim.Linetype = "BYBLOCK"sDim.Lineweight = acLnWt005' Get DimensionStyles collectionSet dCol = ThisDrawing.DimStyles' Erase old "Wannabe_DimStyle" dimstyleOn Error Resume NextdCol.Item("Wannabe_DimStyle").Delete' Add new "Wannabe_DimStyle" dimstyleSet nDim = dCol.Add("Wannabe_DimStyle")[color="#0000ff"]'Copy properties from sample dimension sDim to dimstyle nDim[/color]nDim.CopyFrom (sDim)' Delete sample dimensionsDim.DeleteEnd Sub
 
Look for all dimension properties in Developer Help articles.
回复

使用道具 举报

21

主题

146

帖子

127

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
106
发表于 2022-7-6 18:12:07 | 显示全部楼层
Ok, I am now getting close to my required targets for creating a dimension style; using an aligned dimension to copy the properties from.
 
The problem I have is that I cannot locate any method or code that will allow me to set the linetype of the extension and dimension lines.
 
Everything else is perfect.
回复

使用道具 举报

2

主题

439

帖子

536

银币

限制会员

铜币
-14
发表于 2022-7-6 18:16:46 | 显示全部楼层
 
Yes this properties missed in Developer Help, therefore if you will look methods and properties of DimAligned in Object Browser you find DimensionLinetype,  ExtLine1Linetype and ExtLine2Linetype properties. All used linetypes must be loaded with Load method before you will use it.
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

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

© 2020-2025 乐筑天下

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