Add thicken to all Surface one by one

Add thicken to all Surface one by one

Darkforce_the_ilogic_guy
Advisor Advisor
685 Views
1 Reply
Message 1 of 2

Add thicken to all Surface one by one

Darkforce_the_ilogic_guy
Advisor
Advisor

 

 

Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveDocument

 Dim oDef As PartComponentDefinition
 oDef = oDoc.ComponentDefinition
Dim NumberOfSelevsion
NumberOfSelevsion =oDoc.SelectSet.Count

For i = 1 To NumberOfSelevsion 
	

	Try
 Dim oFace As Face

 oFace = oDoc.SelectSet(NumberOfSelevsion)
 

 Dim oFaceColl As FaceCollection
 oFaceColl = ThisApplication.TransientObjects.CreateFaceCollection

 oFaceColl.Add(oFace)
 'oFaceColl.Clear
 

 Dim oThicken As ThickenFeature
 
 oThicken = oDef.Features.ThickenFeatures.Add(oFaceColl, "0.1 in", kPositiveExtentDirection, kJoinOperation)
 'oFaceColl.Clear
 Catch
	 
 End Try
 
  
 Next

I have this code ... it work fine in I want to add thickness to one surface add the time ... but I want to add surface thinkness to all surface .. one by one sind something it give a error if you try a grounp at the time .. but would like to know how to take all at ons... and I do not want to have to select them .

 

how can i do this 

 

Udklip.PNG

 

0 Likes
686 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable

Hello,

If you need to thicken all faces in a body (assuming this is a part), you could reach for the surfacebody object.

 

I tried the following code on a simple box shaped object and it thickened it on every side equally:

'VBA code, you probably have to remove the 'set' stuff to get it working in Ilogic
Sub ThickenAllFaces() Dim oPartDoc As PartDocument Set oPartDoc = ThisApplication.ActiveDocument Dim oSMDef As SheetMetalComponentDefinition Set oSMDef = oPartDoc.ComponentDefinition Dim oFaceCol As FaceCollection Set oFaceCol = ThisApplication.TransientObjects.CreateFaceCollection Dim oFace As Face For Each oFace In oSMDef.SurfaceBodies.Item(1).Faces Call oFaceCol.Add(oFace) Next Dim oThickFeat As ThickenFeature Set oThickFeat = oSMDef.Features.ThickenFeatures.Add(oFaceCol, 0.1, kPositiveExtentDirection, kJoinOperation) End Sub

I should remind you that Im referring to a sheetmetal part and thus a sheetmetalcomponentdefinition. you should adjust that to your own part definition.

it might also help that the help page about the feature indicated that every face in the facecollection must be connected. 

If your part has multiple bodies, you should iterate over every body as well. if so, I suggest adding a thickenfeature to every solid body instead of just one for all (because the connected face requirement).

 

Hope this solved your issue,

 

Peter Verheijen

0 Likes