Hi,
i wanna making a extrusion from every select line in Part
/code
Public Sub test()
Dim oPartdoc As PartDocument
Set oPartdoc = ThisApplication.ActiveDocument
Dim oCompDef As PartComponentDefinition
Set oCompDef = oPartdoc.ComponentDefinition
Dim oSelectSet As SelectSet
Set oSelectSet = oPartdoc.SelectSet
If oSelectSet.Count = 0 Then
Exit sub
end if
Dim oSketch As PlanarSketch
Set oSketch = oCompDef.Sketches.item(1)
Dim oSketchLine As SketchLine
Set oSketchLine = oSelectSet.item(1)
Dim oSketch As Sketch
Set oSketch = oSketchLine.Parent
Dim oProfile As Profile
Set oProfile = oSketch.Profiles.AddForSurface
Dim oCutExtrude As ExtrudeFeature
Set oCutExtrude = oCompDef.Features.ExtrudeFeatures.AddByDistanceExtent(oProfile, 1, PartFeatureExtentDirectionEnum.kSymmetricExtentDirection, PartFeatureOperationEnum.kSurfaceOperation)
end sub
/code
so this code dosent work any one can help me please
thx
Solved! Go to Solution.
Solved by mario.lung. Go to Solution.
Hi,
It is not clear to me why you re-defined oSketch. So I just commented out one definition
' Dim oSketch As PlanarSketch
' Set oSketch = oCompDef.Sketches.Item(1)
Dim oSketchLine As SketchLine
Set oSketchLine = oSelectSet.Item(1)
Dim oSketch As Sketch
Set oSketch = oSketchLine.Parent
And I selected any sketch line in one sketch, run your code, the result works fine to me. Please see the attached screenshot.
Best regards,
Xiaodong Liang
Developer Consultant
Autodesk Developer Technical Services
Hi,
thx for your help because its not working right
create 2 lines select the last create line and start the code
you can see now it makes the extrusion always on the first inserted line 😞 and not on the selected secound line 😞
thx
Mario
I Solved the Problem now with
Dim oProfile As Profile Set oProfile = oSketch.Profiles.AddForSurface(oSketchLine)
thx
how can i activate sketch command in vba?
i want to add a projected line from a face i will select.
thanks
Hi,
you mean this?
as example
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument
' Create the new sketched symbol definition.
Dim oSketchedSymbolDef As SketchedSymbolDefinition
Set oSketchedSymbolDef = oDrawDoc.SketchedSymbolDefinitions.Add("Faltmarken_A1")
Dim oSketch As DrawingSketch
Call oSketchedSymbolDef.Edit(oSketch)
cu
Mario
i need the code for ipt or iam to create a projected line from a solid.
executing the sketch command is good enough for me.