How to get the definition out of an include workfeature in a drawing

How to get the definition out of an include workfeature in a drawing

Anonymous
Not applicable
586 Views
8 Replies
Message 1 of 9

How to get the definition out of an include workfeature in a drawing

Anonymous
Not applicable
Hello,

A drawing (idw) has a centermark, which is an icluded workfeature of a ThreePlanesWorkpoint type.
In the following example I want to get the name of the first plane of this workpoint.

Dim oCentermark As Centermark
Dim oWorkpoint As WorkPoint
Dim oWorkpointDef As ThreePlanesWorkPointDef
Dim oPlane1 As WorkPlane

'' The active document is an idw
'' Assuming the first selected item is a ThreePlanesWorkpoint

Set oCentermark = ThisApplication.ActiveDocument.SelectSet(1)
Set oWorkpoint = oCentermark.AttachedEntity
Set oWorkpointDef = oWorkpoint.Definition
Set oPlane1 = oWorkpointDef.Plane1

MsgBox (oWorkpoint.Name)
MsgBox (oPlane1.Name)

The program stops at the line Set oWorkpointDef = oWorkpoint.Definition with the error message;
Run-time error'445':Object doesn't support this action

Does anyone know another way of getting to the name of the first plane? Edited by: PeterKingma on Feb 25, 2010 12:08 PM
0 Likes
587 Views
8 Replies
Replies (8)
Message 2 of 9

Anonymous
Not applicable
Your code worked for me.
Have you put a watch on oWorkpoint and looked to see what the definition is
showing?

--
KWiKMcad
Kent Keller
"PeterKingma" wrote in message news:6343899@discussion.autodesk.com...
Hello,

A drawing (idw) has a centermark, which is an icluded workfeature of a
ThreePlanesWorkpoint type.
In the following example I want to get the name of the first plane of this
workpoint.

Dim oCentermark As Centermark
Dim oWorkpoint As WorkPoint
Dim oWorkpointDef As ThreePlanesWorkPointDef
Dim oPlane1 As WorkPlane

'' The active document is an idw
'' Assuming the first selected item is a ThreePlanesWorkpoint

Set oCentermark = ThisApplication.ActiveDocument.SelectSet(1)
Set oWorkpoint = oCentermark.AttachedEntity
Set oWorkpointDef = oWorkpoint.Definition
Set oPlane1 = oWorkpointDef.Plane1

MsgBox (oWorkpoint.Name)
MsgBox (oPlane1.Name)

The program stops at the line Set oWorkpointDef =
oWorkpoint.Definition
with the error message;
Run-time error'445':Object doesn't support this action

Does anyone know another way of getting to the name of the first plane?

Edited by: PeterKingma on Feb 25, 2010 12:08 PM
0 Likes
Message 3 of 9

Anonymous
Not applicable
Hallo Kent,

Thanks for your reply.

During runtime
oWorkpointDef = nothing
oWorkpoint.Definition = Object doesn't support this action

When I discard the oCentermark and select the workpoint directly from the ipt it works correctly.

Dim oWorkpoint As WorkPoint
Dim oWorkpointDef As ThreePlanesWorkPointDef
Dim oPlane1 As WorkPlane

'' The active document is an ipt
'' Assuming the first selected item is a ThreePlanesWorkpoint

Set oWorkpoint = ThisApplication.ActiveDocument.SelectSet(1)
Set oWorkpointDef = oWorkpoint.Definition
Set oPlane1 = oWorkpointDef.Plane1

MsgBox (oWorkpoint.Name)
MsgBox (oPlane1.Name)


The only thing is that I must have it from within the idw!
0 Likes
Message 4 of 9

Anonymous
Not applicable
Hello Kent,

The watch on the oWorkpoint says by definition; Application-defined or object-defined error Edited by: PeterKingma on Feb 26, 2010 11:49 AM
0 Likes
Message 5 of 9

Anonymous
Not applicable
This works for me too. I am selecting the center mark in the drawing and
running your code. The AttachedEntity property returns the WorkPoint in the
part so any code after that should behave just the same as if you had
accessed the WorkPoint directly in the part.
--
Brian Ekins
Inventor API Product Designer
http://blogs.autodesk.com/modthemachine
0 Likes
Message 6 of 9

Anonymous
Not applicable
Maybe try to make as small of a sample set as you can and post it.

--
KWiKMcad
Kent Keller
"PeterKingma" wrote in message news:6344816@discussion.autodesk.com...
Hello Kent,

The watch on the oWorkpoint says by definition; Application-defined or
object-defined error

Edited by: PeterKingma on Feb 26, 2010 11:49 AM
0 Likes
Message 7 of 9

Anonymous
Not applicable
As I was making the smallest possible sample and testing this, it worked fine. Than I compared this small sample with the test files I was using. The main difference is that in my test files, the part is in an assembly, and in the drawing the main view is of this assembly. And altough the included work features is from the part, the code seems to access the workpoint throught the assembly correctly, but unfortunately not the workpoint definition.

The question however is, in wich way to get to the definition throught this assembly. I hope you have a solution.

Edited by: PeterKingma on Mar 1, 2010 9:11 AM Edited by: PeterKingma on Mar 1, 2010 5:11 PM
0 Likes
Message 8 of 9

Anonymous
Not applicable
Peter,

Give this a try. Maybe Brian has a better method, but it will get you
started.

Public Sub Workpoint()

Dim oCentermark As Centermark

Dim oWorkpoint As Object
Dim oWorkpointDef As ThreePlanesWorkPointDef
Dim oPlane1 As WorkPlane

Set oCentermark = ThisApplication.ActiveDocument.SelectSet(1)
Set oWorkpoint = oCentermark.AttachedEntity

If TypeOf oWorkpoint Is Workpoint Then
Set oWorkpointDef = oWorkpoint.Definition
ElseIf TypeOf oWorkpoint Is WorkPointProxy Then
Set oWorkpointDef = oWorkpoint.NativeObject.Definition
Else
MsgBox "Workpoint Type is " & oWorkpoint.Type
End If

Set oPlane1 = oWorkpointDef.Plane1

MsgBox (oWorkpoint.Name)
MsgBox (oPlane1.Name)

End Sub


--
KWiKMcad
Kent Keller
"PeterKingma" wrote in message news:6345989@discussion.autodesk.com...
As I was making the smallest possible sample and testing this, it worked
fine. Than I compared this small sample with the test files I was using. The
main difference is that in my test files, the part is in an assembly, and in
the drawing the main view is of this assembly. And altough the included work
features is from the part, the code seems to access the workpoint throught
the assembly correctly, but unfortunately not the workpoint definition.

The question however is, in wich way to get to the definition throught this
assembly. I hope you have a solution.

Edited by: PeterKingma on Mar 1, 2010 9:11 AM

Edited by: PeterKingma on Mar 1, 2010 5:11 PM
0 Likes
Message 9 of 9

Anonymous
Not applicable
Hello Kent,

Yes, this works perfect. Thanks a lot! Just what I needed to finish the complete macro to work.


Thanks!
0 Likes