Line + ExtrudeFeatures.AddByDistanceExtent VB.net or vba

Line + ExtrudeFeatures.AddByDistanceExtent VB.net or vba

Anonymous
Not applicable
914 Views
6 Replies
Message 1 of 7

Line + ExtrudeFeatures.AddByDistanceExtent VB.net or vba

Anonymous
Not applicable

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

 

 

0 Likes
Accepted solutions (1)
915 Views
6 Replies
Replies (6)
Message 2 of 7

xiaodong_liang
Autodesk Support
Autodesk Support

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,

 
autodesk_logo_signature.png

Xiaodong Liang

Developer Consultant

Autodesk Developer Technical Services

0 Likes
Message 3 of 7

Anonymous
Not applicable

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

 

0 Likes
Message 4 of 7

Anonymous
Not applicable
Accepted solution

I Solved the Problem now with

 

 

    Dim oProfile As Profile
    Set oProfile = oSketch.Profiles.AddForSurface(oSketchLine)

 thx

0 Likes
Message 5 of 7

Anonymous
Not applicable

how can i activate sketch command in vba?

 

i want to add a projected line from a face i will select.

 

thanksSmiley Happy

 

 

0 Likes
Message 6 of 7

Anonymous
Not applicable

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

0 Likes
Message 7 of 7

Anonymous
Not applicable

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.

0 Likes