Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations MintJulep on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

API: How Store Temp Axis Selection? 1

Status
Not open for further replies.

brengine

Mechanical
Apr 19, 2001
616
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

 
Replies continue below

Recommended for you

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.
 
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
 
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..
<<
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor