Adding iFeature with VBA failed

Anonymous

Adding iFeature with VBA failed

Anonymous
Not applicable

Hi,

Im trying (and failing) to add an iFeatur to a part using a VBA-Macro.

By pressing F1 on "iFeatures" in the VBA-Editor i found an exampel code but in my case it dosn't work.

I selected a Face in my testpart (attached) and then executed the vba code. It complained that i had to select a "planar face", so i commeted out the lines that checked for the planar face and run the code again. It didn't show any errors but also did not place the iFeature (attached).

I attached the IFeature, my testpart and the VBA code with the plain exampel code and my modified verison.

If anybody has any expeareance with adding features via VBA-Macros, could he or she post an exampel or explain to me how this is done?

Thanks very much

Paul.

0 Likes
Reply
Accepted solutions (1)
405 Views
2 Replies
Replies (2)

frederic.vandenplas
Collaborator
Collaborator
Accepted solution

Hi, 

I managed to let it work.

There were 2 problems, in the sample code the <> is missing

If oFace.SurfaceType <> kPlaneSurface Then
       MsgBox "A planar face must be selected."
       'Exit Sub
    End If

And then it look for a sketchplane in your iFeature.

But Sketch Plane is not available in your iFeature.

So change this

Case "Sketch Plane"

To This

Case "Skizzenposition-Ebene1"

I came across your 2nd problem with a debug.print of the needed input of your specific ifeature

Debug.Print oInput.Name
        Select Case oInput.Name
If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"

Anonymous
Not applicable

@frederic.vandenplas 

Thank you very much for your quick help.

I tried it with the changes you suggestet and it worked flawlessly.

 

I attatched a fully functional exampel for future visitors of this post, the credit for witch belongs to you.

Thanks again and "KUDOS" 👍