Community
Hi,
I'm trying to find out how to change a direction of a hole.
Doeas anybody have an idea why this code wont work on holes?
Dim pdoc As PartDocument = ThisDoc.Document Dim pdef As PartComponentDefinition = pdoc.ComponentDefinition Dim hfea As HoleFeature = pdef.Features.Item("Hole1") Dim extent As DistanceExtent = TryCast(hfea.Extent, DistanceExtent) If extent.Direction = PartFeatureExtentDirectionEnum.kPositiveExtentDirection Then extent.Direction = PartFeatureExtentDirectionEnum.kNegativeExtentDirection ElseIf extent.Direction = PartFeatureExtentDirectionEnum.kNegativeExtentDirection Then extent.Direction = PartFeatureExtentDirectionEnum.kPositiveExtentDirection End If
Regards
Rikard
Solved! Go to Solution.
Solved by JaneFan. Go to Solution.
Hey @rikard.nilsson ,
Please use different set method to change different type extent, code like this:
Dim pdoc As PartDocument = ThisDoc.Document Dim pdef As PartComponentDefinition = pdoc.ComponentDefinition Dim hfea As HoleFeature = pdef.Features.Item("Hole1") Dim extent As DistanceExtent = TryCast(hfea.Extent, DistanceExtent) If extent.Direction = PartFeatureExtentDirectionEnum.kPositiveExtentDirection Then hfea.SetDistanceExtent(hfea.Depth, PartFeatureExtentDirectionEnum.kNegativeExtentDirection ) ' extent.Direction = PartFeatureExtentDirectionEnum.kNegativeExtentDirection ElseIf extent.Direction = PartFeatureExtentDirectionEnum.kNegativeExtentDirection Then hfea.SetDistanceExtent(hfea.Depth, PartFeatureExtentDirectionEnum.kPositiveExtentDirection ) ' extent.Direction = PartFeatureExtentDirectionEnum.kPositiveExtentDirection End If
Can't find what you're looking for? Ask the community or share your knowledge.