×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

API: How Store Temp Axis Selection?

API: How Store Temp Axis Selection?

API: How Store Temp Axis Selection?

(OP)
If I preselect a face, plane, or axis, and then run the following macro...the program will store the selected entity, clear all selections, and then reselect that entity.

CODE

Option Explicit
Dim swApp               As SldWorks.SldWorks
Dim MySWAssembly        As SldWorks.ModelDoc2
Dim swSelMgr            As SldWorks.SelectionMgr
Dim swSelData           As SldWorks.SelectData
Dim MyEntity          As SldWorks.entity
Dim boolstatus As Boolean

Sub main()

   Set swApp = Application.SldWorks
   Set MySWAssembly = swApp.ActiveDoc
   Set swSelMgr = MySWAssembly.SelectionManager
   Set swSelData = swSelMgr.CreateSelectData
   Set MyEntity = swSelMgr.GetSelectedObject5(1)

   MySWAssembly.ClearSelection2 True
   boolstatus = MyEntity.Select4(True, swSelData)

End Sub

If I preselect a temporary axis I get an error on the last (re-select) line.  I just turned on the macro recorder and selected a reference axis and then selected a temporary axis and got this (I trimmed the number entries down to 3 decimals):

CODE

boolstatus = Part.Extension.SelectByID("Axis1", "AXIS", -0.0479, 0.053, 0.003, False, 0, Nothing)
boolstatus = Part.Extension.SelectByID("@BasePart-1@InsertHardware", "AXIS", -0.046, 0.025, 0.030, False, 0, Nothing)

The problem seems to the that the ID name of the temporary axis is missing the first portion of the name.  Does anyone know if this is a bug or of a way to get around this?  Running SW2004 sp4.0.

Thanks,
Ken

RE: API: How Store Temp Axis Selection?

Try using a generic object for MyEntity  .

i.e.

CODE

Dim MyEntity As Object

Also, try stepping through the code one line at a time to see if all the objects are getting assigned properly.  Use your "locals" window to inspect each object.

RE: API: How Store Temp Axis Selection?

(OP)
I converted to:

CODE

Dim MyEntity As Object

It didn't work.  I still get the same error "The object invoked has disconnected from it's clients".

I stepped thru the code and all the objects went from a variable value of "Nothing" to a value of "<No Variables>"...which I have always assumed to be the correct initializing of an object.

This macro works fine for faces, planes, and axes.  It doesn't work for Temporary Axes and I am trying to figure out why.

Thanks anyway,
Ken

RE: API: How Store Temp Axis Selection?

(OP)
FYI, I got this back for API-Support

>>
It looks like I have open SPR 117754 - When QI a temporary Axis for the entity interface, you get a valid entity pointer how ever when you call select .. nothing..
<<

RE: API: How Store Temp Axis Selection?

Thanks for the follow up, Ken.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources