以下代码假设为钟面。dwg块与当前图形位于同一文件夹中:
-
- Option Explicit
- Public Sub InsertClock()
- Dim objBRef As AcadBlockReference
- Dim varPoint As Variant
- Dim intMin As Integer
- Dim intHour As Integer
- Dim BProps As Variant
- Dim tmpProp As AcadDynamicBlockReferenceProperty
- Dim intI As Integer
- 'ask user for where to place the clock, the prompt goes
- ' through the command window
- varPoint = ThisDrawing.Utility.GetPoint(, "click where you want the clock")
- 'ask for time
- intHour = ThisDrawing.Utility.GetInteger(vbCrLf & "Hour: ")
- intMin = ThisDrawing.Utility.GetInteger(vbCrLf & "Minute: ")
- 'insert block (the ones and zeros are for scale and rotation)
- Set objBRef = ThisDrawing.ModelSpace.InsertBlock(varPoint, "ClockFace.dwg", 1, 1, 1, 0)
- 'get properties of the block
- BProps = objBRef.GetDynamicBlockProperties
- 'go find minute and hour properties and change them
- 'the minute rotation property is called 'Angle'
- 'the hour rotation property is called 'Angle1'
- For intI = LBound(BProps) To UBound(BProps)
- 'grab one property
- Set tmpProp = BProps(intI)
- 'check for minute hand
- If tmpProp.PropertyName = "Angle" Then
- tmpProp.Value = Math.Atn(1) * 4 - (CDbl(intMin) / 60) * 2 * Math.Atn(1) * 4 - 2 * Math.Atn(1)
- End If
- 'check for hour hand
- If tmpProp.PropertyName = "Angle1" Then
- tmpProp.Value = Math.Atn(1) * 4 - (CDbl(intHour) / 12) * 2 * Math.Atn(1) * 4 - 2 * Math.Atn(1)
- End If
- Next intI
- 'update block
- objBRef.Update
- End Sub
好的,现在我想修改一下这段代码,我只是不知道语法。我希望当用户选择一个点插入时钟时,时钟的虚线版本沿着光标跟随。你知道我的意思吗?它使它变得专业,当你需要查看时钟需要去哪里时,它变得更容易。
谢谢
~老虎1337 |