Extrude each profile in a sketch

Extrude each profile in a sketch

ngocson8335
Advocate Advocate
466 Views
2 Replies
Message 1 of 3

Extrude each profile in a sketch

ngocson8335
Advocate
Advocate

Hello Everyone,

 

My name is Son. I am trying to extrude each profile in a sketch with new solid but I can not find the API to do that. Please help me in this case.

 

Screenshot:

Extrude for each profile in a ketch.png

Many thanks.

Ngoc Son
Autodesk User
0 Likes
467 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor

This is regular iLogic (VB.net), not API (VBA), but its easily convertible by adding a 'Set',  and a 'Call' or few in there.  After finding the Sketch, it sets it as Shared, so that it can be used by multiple ExtrudeFeatures if needed.  Then it basically just goes another step deeper in the Profile to its ProfileFaths, checks whether they are 'Closed' or not, then sets its '.AddsMaterial' property.

I think you can play around with this idea to achieve your goal.

Dim oDoc As PartDocument = ThisApplication.ActiveDocument
Dim oCompDef As PartComponentDefinition = oDoc.ComponentDefinition
Dim oSketch As PlanarSketch = oCompDef.Sketches.Item(1)
oSketch.Shared = True
Dim oProfiles As Profiles = oSketch.Profiles
For Each oProfile As Profile In oPrfiles
	If oProfile.Count > 1 Then
		For i = 1 To oProfile.Count
			If oProfile.Item(i).Closed = True Then
				oProfile.Item(i).AddsMaterial = True
			End If
		Next
	End If
	oProfiles.AddForSolid ' You can modify the Optional Parameters of this if needed.
	Dim oExtFeats As ExtrudeFeatures = oCompDef.Features.ExtrudeFeatures
	Dim oExtrudeDef As ExtrudeDefinition
	oExtrudeDef = oExtFeats.CreateExtrudeDefinition(oProfile, PartFeatureOperationEnum.kNewBodyOperation)
	oExtrudeDef.SetDistanceExtent(10, PartFeatureExtentDirectionEnum.kPositiveExtentDirection)
	Dim oExtrude As ExtrudeFeature
	oExtrude = oExtFeats.Add(oExtrudeDef)
Next

Check out the following link for additional info.

http://help.autodesk.com/view/INVNTOR/2020/ENU/?guid=GUID-5A9FA7CB-1EB9-4849-BB9D-11AD01F3DBF6 

And this example

http://help.autodesk.com/view/INVNTOR/2020/ENU/?guid=GUID-E9592972-C31C-4800-9699-C069E5C92BC3 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

ngocson8335
Advocate
Advocate

Hello Mr.

Thanks for your help.

I just put your code to the Visual Studio but after running, the first solid did not show on the model display and it is stopped for the second time.

Error screenshot:

screenshot_1576722614.png

Many thanks,

Ngoc Son

Ngoc Son
Autodesk User
0 Likes