Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Reversing Reference plane direction (API) 1

Status
Not open for further replies.

cpretty

Mechanical
Oct 9, 2001
113
Does anyone know how to change the direction of a reference plane. I have a reference plane (say "Plane4") that I would like to reverse direction. It will always be this plane so I would prefer to reference it directly eg SelectByID.

I can't even find any help by recording a macro of the process, as when run it creates a new plane instead of modifying it.
 
Replies continue below

Recommended for you

From the Feature, you'll use these methods:
Code:
Feature.GetDefinition
RefPlaneFeatureData.AccessSelections
RefPlaneFeatureData::ReverseDirection
RefPlaneFeatureData::ReleaseSelectionAccess

From Help > SolidWorks API Help Topics, look under:
SolidWorks Objects
  Feature Objects
    Reference Geometry
      RefPlaneFeatureData
DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
I've had a bit of a bash at this sort of thing for work. It sounds like you are having very similar problems with the incomprehensibly incomplete help files available. In truth I only got this going through trial and error!

My only hint, use Set lots!

Sub main()

Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc

'This sets the handle for the plane and gets back it's definition.
Set PlaneFeature = Part.FeatureByName("Insert your plane name here")
Set PlaneObject = PlaneFeature.GetSpecificFeature
Set Plane_DEF = PlaneFeature.GetDefinition

'This turns on the access to the feature (rolling back)
Plane_DEF.AccessSelections Part, Nothing
flip = Plane_DEF.ReverseDirection

'This finds out what flip is and changes it
If flip Then
flip = False
Else
flip = True
End If

'This re-enters the infor into the feature definition, updates the feature definition and then closes the access (rolls down).
Plane_DEF.ReverseDirection = flip
PlaneObject.ModifyDefinition Plane_DEF, Part, Nothing
Plane_DEF.ReleaseSelectionAccess
End Sub
 
Thankyou very much. The solution works. Who would have thought that so many set commands were required.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor