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

Status
Not open for further replies.

Baruch

Mechanical
Feb 25, 2004
13
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
==================================================
 
Replies continue below

Recommended for you

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.
 
Thank's a lot, you probably right.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor