×
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 - Auto size ref. planes in a part

API - Auto size ref. planes in a part

API - Auto size ref. planes in a part

(OP)
Hi, what I try to do is to make "Autosize" all the ref. planes in the part as it is done with RMB and "Autosize".
The macro is running without errors but the job is not done.
I would appreciate some help, 10x!

'==========================================The Code======
Sub Main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swFeature As SldWorks.feature
Dim rfPl As SldWorks.RefPlaneFeatureData

Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc

Set swFeature = swModel.FirstFeature

Do While Not swFeature Is Nothing
    Debug.Print swFeature.GetTypeName
    If swFeature.GetTypeName = "RefPlane" Then
               
        Set rfPl = swFeature.GetDefinition
        rfPl.autoSize = True
    
    End If
Set swFeature = swFeature.GetNextFeature
Loop
MsgBox ("Finish")
End Sub
==================================================

RE: API - Auto size ref. planes in a part

I have good news and bad news for you.  First, the good news:

After the line "rfPl.autoSize = True" you need to insert the following line:

bRet = swFeature.ModifyDefinition(rfPl, swModel, Nothing)

(Of course, make sure you specify bRet as a boolean.)

What this does is apply the feature data changes you made to the feature itself.  Now for the bad news:  Even after you add this line, it still won't autosize your planes.  So that means I'm missing something too, right?  Well, I don't think so.  The reason I say that is because I created a reference plane in addition to the Front, Top and Side that already exist, and I was able to flip it about its reference plane by changing the "ReverseDirection" data field.  Once I had that working, I added the line to change the "AutoSize" data field as well.  It did not work.  I was able to create new planes that were autosized; I just couldn't autosize existing ones.

Unless I'm seriously missing something, this would appear to be a bug in the API.

RE: API - Auto size ref. planes in a part

(OP)
Thank's a lot, you probably right.

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