File tree Expand file tree Collapse file tree 3 files changed +59
-0
lines changed
solidworks-api/document/dimensions/set-read-only Expand file tree Collapse file tree 3 files changed +59
-0
lines changed Original file line number Diff line number Diff line change 1+ Const READ_ONLY As Boolean = True
2+
3+ Dim swApp As SldWorks .SldWorks
4+ Dim swModel As SldWorks .ModelDoc2
5+
6+ Sub main ()
7+
8+ Set swApp = Application.SldWorks
9+
10+ Set swModel = swApp.ActiveDoc
11+
12+ Dim swSelMgr As SldWorks .SelectionMgr
13+
14+ Set swSelMgr = swModel.SelectionManager
15+
16+ Dim swFeat As SldWorks .Feature
17+
18+ Set swFeat = swSelMgr.GetSelectedObject6(1 , -1 )
19+
20+ If Not swFeat Is Nothing Then
21+
22+ Dim swDispDim As SldWorks .DisplayDimension
23+
24+ Set swDispDim = swFeat.GetFirstDisplayDimension
25+
26+ While Not swDispDim Is Nothing
27+
28+ Dim swDim As SldWorks .Dimension
29+
30+ Set swDim = swDispDim.GetDimension2(0 )
31+ swDim.ReadOnly = READ_ONLY
32+
33+ Set swDispDim = swFeat.GetNextDisplayDimension(swDispDim)
34+
35+ Wend
36+
37+ Else
38+ Err.Raise vbError, "" , "Select feature"
39+ End If
40+
41+ End Sub
Original file line number Diff line number Diff line change 1+ ---
2+ caption : Set To Read-Only
3+ title : Macro to change read-only state of all dimensions of the selected feature in the SOLIDWORKS model
4+ description : VBA macro to change the read-only options for all dimensions of the selected feature of the active SOLIdWORKS model
5+ image : dimension-read-only.png
6+ ---
7+
8+ ![ Dimension read-only property] ( dimension-read-only.png ) { width=400 }
9+
10+ This SOLIDWORKS VBA macro changes the read-only state of all dimensions of the selected feature (e.g. sketch).
11+
12+ Set the target read-only state in the constant
13+
14+ ~~~ vb
15+ Const READ_ONLY As Boolean = True 'True to set to Read-Only, False to remove Rea-Only flag
16+ ~~~
17+
18+ {% code-snippet { file-name: Macro.vba } %}
You can’t perform that action at this time.
0 commit comments