Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

INVENTOR API - CREATE FEATURE IN ACTIVEDITDOCUMNET

Khoa_NguyenDang
Advocate

INVENTOR API - CREATE FEATURE IN ACTIVEDITDOCUMNET

Khoa_NguyenDang
Advocate
Advocate

HI all guys 

 

I want to create the feature in the ActiveEditDocument link in the attached picture 

But I use the same code to create features in IPT, but when I edit 1 component in Assembly, I call the same code but it not work 

Do any people know about this, please help me

Thank you so much !!!!

 

Khoa_NguyenDang_0-1609175537252.png

 

0 Likes
Reply
Accepted solutions (1)
1,026 Views
5 Replies
Replies (5)

dutt.thakar
Collaborator
Collaborator
Accepted solution

@Khoa_NguyenDang 

 

Are you looking for something like this?

 

 

 

 

 

 

If this answer has solved your problem please ACCEPT SOLUTION and hit like if you found it helpful..!


Regards,
Dutt Thakar
LinkedIn
0 Likes

Khoa_NguyenDang
Advocate
Advocate

Hi @dutt.thakar 

Yes, it like in your video

Can you take a look with your code, thank you

0 Likes

dutt.thakar
Collaborator
Collaborator

@Khoa_NguyenDang 

 

Please see the code below. I am just creating a circular profile extrude in the code, please change it as per your requirement. Make sure you are in edit state inside the assembly within the part and then run this code.

 

Dim oPartDoc As PartDocument

oPartDoc = ThisApplication.ActiveEditDocument

'Set Component Definition
Dim oCompDef As PartComponentDefinition
oCompDef = oPartDoc.ComponentDefinition

'Create a sketch on XY Plane
Dim oSketch As PlanarSketch
oSketch = oCompDef.Sketches.Add(oCompDef.WorkPlanes.Item(3))

'Draw a Circle
Call oSketch.SketchCircles.AddByCenterRadius(ThisApplication.TransientGeometry.CreatePoint2d(0, 0), 10)

Dim oProfile As Profile
oProfile = oSketch.Profiles.AddForSolid

'Create an Extrusion
Dim oExtrude As ExtrudeFeature
oExtrude = oCompDef.Features.ExtrudeFeatures.AddByDistanceExtent(oProfile, 10, kSymmetricExtentDirection, kNewBodyOperation)

 

Also if you want to detect whether the in-place edit session is active or not. Check the below link, it has some quite useful information.

https://adndevblog.typepad.com/manufacturing/2013/01/detect-in-place-edit-session-in-inventor.html

 

 

Hope this will be helpful.

 

 

If this answer has solved your problem please ACCEPT SOLUTION and hit like if you found it helpful..!


Regards,
Dutt Thakar
LinkedIn
0 Likes

Khoa_NguyenDang
Advocate
Advocate

HI @dutt.thakar 

I couldn't use the Thicken function in ActveEditDocument 

but I also try with Combine function and it works

Do you have any advice for me. Thank you

0 Likes

dutt.thakar
Collaborator
Collaborator

@Khoa_NguyenDang 

 

I have created the code in VBA for a test and it works perfectly, Check out the below screencast and code as well. The code is in VBA, so please note that you need to convert it to make it work in VB.Net or C#.

 

 

 

 

Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.ActiveEditDocument

Dim oCompDef As PartComponentDefinition
Set oCompDef = oPartDoc.ComponentDefinition

Dim oFeat As PartFeature
FCount = 1
Dim oFaceCol As FaceCollection
Set oFaceCol = ThisApplication.TransientObjects.CreateFaceCollection
For Each oFeat In oCompDef.Features
If InStr((oFeat.Name), "Patch") Then
oFaceCol.Clear
For Each oFace In oFeat.SurfaceBodies.Item(1).Faces
Call oFaceCol.Add(oFace)
Dim oThickFeat As ThickenFeature
Set oThickFeat = oCompDef.Features.ThickenFeatures.Add(oFaceCol, "0.4", kSymmetricExtentDirection, kNewBodyOperation, True)
oThickFeat.Name = "Thicken-Partition" & FCount
FCount = FCount + 1
Next
End If
Next
End Sub

 
 
 
 
Hope this will be helpful.
If this answer has solved your problem please ACCEPT SOLUTION and hit like if you found it helpful..!


Regards,
Dutt Thakar
LinkedIn
0 Likes