Select?

Select?

Anonymous
Not applicable
364 Views
2 Replies
Message 1 of 3

Select?

Anonymous
Not applicable
Hi everyone.

I'm trying with the code below to show all feature dimensions, and then when i select one of them i want to display the parameter name of the dimension, but the following code only allows me to pick sketch diemsions and it´s not working for feature dimensions (ex: extrude distance), so what should i do?, Thanks.

Option Explicit

Private WithEvents oInteraction As InteractionEvents
Private WithEvents oSelect As SelectEvents

Private Sub UserForm_Initialize()

Dim i As Integer

Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveDocument

Dim oDef As PartComponentDefinition
Set oDef = oDoc.ComponentDefinition

Dim oSelectSet As SelectSet
Set oSelectSet = ThisApplication.ActiveDocument.SelectSet

oSelectSet.Clear

For i = 1 To oDoc.ComponentDefinition.Features.count

oSelectSet.Select oDoc.ComponentDefinition.Features(i)

Dim oControlDef As ControlDefinition
Set oControlDef = ThisApplication.CommandManager.ControlDefinitions.Item("PartShowDimensionsCtxCmd")

oControlDef.Execute

Next i

oSelectSet.Clear

' Create a new InteractionEvents object.
Set oInteraction = ThisApplication.CommandManager.CreateInteractionEvents

' Set the prompt.
oInteraction.StatusBarText = "Pick dimensions constraints from the model."

' Connect to the associated select events.
Set oSelect = oInteraction.SelectEvents


' Enable single selection.
oSelect.SingleSelectEnabled = True

' Start the selection process.
oInteraction.Start

End Sub

Private Sub oSelect_OnSelect(ByVal JustSelectedEntities As ObjectsEnumerator, _
ByVal SelectionDevice As SelectionDeviceEnum, _
ByVal ModelPosition As Point, _
ByVal ViewPosition As Point2d, _
ByVal View As View)


Dim i As Long
Dim dLength As Double
Dim odim As DimensionConstraint

If JustSelectedEntities.Type = kDimensionConstraintsObject then
msgbox= odim.Parameter.Name
End If

End Sub
0 Likes
365 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable

The extruded distance (or angle of revolution for
Revolved features) are not going to be of type kDimensionContraintsObject. 
Only the 2D sketch dimensions will fall into that category.  I don't know
what the object type of an extruded distance (or again, angle of revolution,
etc.) would be, but maybe if you remove the If statement and replace it with an
error trap, it would work.  Something like this:

 

On Error Goto DimError

msgbox = odim.Parameter.Name

Exit Sub

 

DimError:

Msgbox "Selected entity is not a
dimension."

 

End Sub

 

I haven't tried this so it's just a
theory.




Brian R.
Iwaskewycz


style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">CAD Systems
Manager


style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana">
href="http://www.corefurnace.com">Core Furnace Systems

0 Likes
Message 3 of 3

Anonymous
Not applicable
I suppose you are talking about the selection not working (the display of
these dimensions works fine). Unfortunately, selection of feature dimensions
is not currently supported in the API. But, we are aware of this and there
currently is a wishlist filed for this. So, it might be provided in a future
release.

-Venkatesh Thiyagarajan.

wrote in message news:5242256@discussion.autodesk.com...
Hi everyone.

I'm trying with the code below to show all feature dimensions, and then when
i select one of them i want to display the parameter name of the dimension,
but the following code only allows me to pick sketch diemsions and it´s not
working for feature dimensions (ex: extrude distance), so what should i do?,
Thanks.

Option Explicit

Private WithEvents oInteraction As InteractionEvents
Private WithEvents oSelect As SelectEvents

Private Sub UserForm_Initialize()

Dim i As Integer

Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveDocument

Dim oDef As PartComponentDefinition
Set oDef = oDoc.ComponentDefinition

Dim oSelectSet As SelectSet
Set oSelectSet = ThisApplication.ActiveDocument.SelectSet

oSelectSet.Clear

For i = 1 To oDoc.ComponentDefinition.Features.count

oSelectSet.Select oDoc.ComponentDefinition.Features(i)

Dim oControlDef As ControlDefinition
Set oControlDef =
ThisApplication.CommandManager.ControlDefinitions.Item("PartShowDimensionsCtxCmd")

oControlDef.Execute

Next i

oSelectSet.Clear

' Create a new InteractionEvents object.
Set oInteraction =
ThisApplication.CommandManager.CreateInteractionEvents

' Set the prompt.
oInteraction.StatusBarText = "Pick dimensions constraints from the
model."

' Connect to the associated select events.
Set oSelect = oInteraction.SelectEvents


' Enable single selection.
oSelect.SingleSelectEnabled = True

' Start the selection process.
oInteraction.Start

End Sub

Private Sub oSelect_OnSelect(ByVal JustSelectedEntities As
ObjectsEnumerator, _
ByVal SelectionDevice As SelectionDeviceEnum, _
ByVal ModelPosition As Point, _
ByVal ViewPosition As Point2d, _
ByVal View As View)


Dim i As Long
Dim dLength As Double
Dim odim As DimensionConstraint

If JustSelectedEntities.Type = kDimensionConstraintsObject then
msgbox= odim.Parameter.Name
End If

End Sub
0 Likes