Page 1 of 1

How to use the AddExtrudedSolid method?

Posted: Sat Oct 19, 2024 11:58 am
by verdant
Hi everyone,
I am trying AddExtrudedSolid method and hope to draw a 10*10*10 cube
but when the programe goes on the AddExtrudedSolid method line
It crashed
here is my code

Code: Select all

Sub try_AddExtrudedSolid()

'Declare
'Long
Dim i As Long
'Line
Dim ActLine As IntelliCAD.Line
'Collection
Dim EdgeClctn As New Collection
'Entity
Dim Edges() As IntelliCAD.Entity
'Solid3D
Dim solidObj As IntelliCAD.Solid3D
'Variant
Dim regionObj As Variant

'Code Zone
'set Edges
EdgeClctn.Add Library.CreatePoint(0, 0, 0)
EdgeClctn.Add Library.CreatePoint(0, 10, 0)
EdgeClctn.Add Library.CreatePoint(10, 10, 0)
EdgeClctn.Add Library.CreatePoint(10, 0, 0)

'Draw Curves
ReDim Edges(0 To EdgeClctn.Count - 1)
For i = 1 To EdgeClctn.Count - 1
    Set ActLine = ActiveDocument.ModelSpace.AddLine(EdgeClctn(i), EdgeClctn(i + 1))
    Set Edges(i - 1) = ActLine
Next i

Set ActLine = ActiveDocument.ModelSpace.AddLine(EdgeClctn(i), EdgeClctn(1))
Set Edges(i - 1) = ActLine

'Draw Region
regionObj = ActiveDocument.ModelSpace.AddRegion(Edges)

' Create the solid
Set solidObj = ActiveDocument.ModelSpace.AddExtrudedSolid(regionObj(0), 10, 0) ''' Here is the crash point!
regionObj(0).Delete

End Sub


Can someone help me to find out the mistake or provid me some sample about the AddExtrudedSolid method?
Any help with this is appreciated.
Thank you.

Re: How to use the AddExtrudedSolid method?

Posted: Mon Oct 21, 2024 7:40 am
by QuanNguyen
Hi,
Maybe something is wrong with AddRegion, it works if the user selects an existing region.

Code: Select all

Sub try_AddExtrudedSolid()
    ' get the entity.
    Dim ent As Entity
    Dim reg As Region
    Dim pt As Point
    
    Dim solidObj As IntelliCAD.Solid3D
    
    ActiveDocument.Utility.GetEntity ent, pt, "Select Entity"
    If ent.EntityType = vicRegion Then
        Set reg = ent
        Set solidObj = ActiveDocument.ModelSpace.AddExtrudedSolid(reg, 10, 0)
    End If
End Sub

Re: How to use the AddExtrudedSolid method?

Posted: Mon Oct 21, 2024 8:39 pm
by verdant
QuanNguyen wrote:
Mon Oct 21, 2024 7:40 am
Hi,
Maybe something is wrong with AddRegion, it works if the user selects an existing region.

Code: Select all

Sub try_AddExtrudedSolid()
    ' get the entity.
    Dim ent As Entity
    Dim reg As Region
    Dim pt As Point
    
    Dim solidObj As IntelliCAD.Solid3D
    
    ActiveDocument.Utility.GetEntity ent, pt, "Select Entity"
    If ent.EntityType = vicRegion Then
        Set reg = ent
        Set solidObj = ActiveDocument.ModelSpace.AddExtrudedSolid(reg, 10, 0)
    End If
End Sub
Thank you Quan,
I tried your code and it works,
but here is another question,
what is the right way to use the AddRegion method in intellicad?
My code about AddRegion is copied from internet somewhere used in Autocad,
and I can't find any example about AddRegion method in Intellicad.
Can you give me some help?
Appreciate your help very much!!

Re: How to use the AddExtrudedSolid method?

Posted: Tue Oct 22, 2024 1:48 am
by QuanNguyen
Hi Verdant,
While waiting for feedback from the support team, try using the last entity in the drawing instead.

Code: Select all

Sub try_AddExtrudedSolid()
    'Declare
    'Long
    Dim i As Long
    'Line
    Dim ActLine As IntelliCAD.Line
    'Collection
    Dim EdgeClctn As New Collection
    'Entity
    Dim Edges() As IntelliCAD.Entity
    'Solid3D
    Dim solidObj As IntelliCAD.Solid3D    
    'Code Zone
    'set Edges
    EdgeClctn.Add Library.CreatePoint(0, 0, 0)
    EdgeClctn.Add Library.CreatePoint(0, 10, 0)
    EdgeClctn.Add Library.CreatePoint(10, 10, 0)
    EdgeClctn.Add Library.CreatePoint(10, 0, 0)   

    'Draw Curves
    ReDim Edges(0 To EdgeClctn.Count - 1)
    For i = 1 To EdgeClctn.Count - 1
        Set ActLine = ActiveDocument.ModelSpace.AddLine(EdgeClctn(i), EdgeClctn(i + 1))
        Set Edges(i - 1) = ActLine
    Next i
    
    Set ActLine = ActiveDocument.ModelSpace.AddLine(EdgeClctn(i), EdgeClctn(1))
    Set Edges(i - 1) = ActLine
    
    'Draw Region
    ActiveDocument.ModelSpace.AddRegion (Edges)

    ' Add Solid
    Dim entLast As Entity
    Set entLast = ActiveDocument.ModelSpace.Item(ActiveDocument.ModelSpace.Count - 1)
    If entLast.EntityType = vicRegion Then
        Set reg = entLast
        Set solidObj = ActiveDocument.ModelSpace.AddExtrudedSolid(reg, 10, 0)
    End If
End Sub

Re: How to use the AddExtrudedSolid method?

Posted: Thu Oct 24, 2024 8:23 pm
by verdant
QuanNguyen wrote:
Tue Oct 22, 2024 1:48 am
Hi Verdant,
While waiting for feedback from the support team, try using the last entity in the drawing instead.

Code: Select all

Sub try_AddExtrudedSolid()
    'Declare
    'Long
    Dim i As Long
    'Line
    Dim ActLine As IntelliCAD.Line
    'Collection
    Dim EdgeClctn As New Collection
    'Entity
    Dim Edges() As IntelliCAD.Entity
    'Solid3D
    Dim solidObj As IntelliCAD.Solid3D    
    'Code Zone
    'set Edges
    EdgeClctn.Add Library.CreatePoint(0, 0, 0)
    EdgeClctn.Add Library.CreatePoint(0, 10, 0)
    EdgeClctn.Add Library.CreatePoint(10, 10, 0)
    EdgeClctn.Add Library.CreatePoint(10, 0, 0)   

    'Draw Curves
    ReDim Edges(0 To EdgeClctn.Count - 1)
    For i = 1 To EdgeClctn.Count - 1
        Set ActLine = ActiveDocument.ModelSpace.AddLine(EdgeClctn(i), EdgeClctn(i + 1))
        Set Edges(i - 1) = ActLine
    Next i
    
    Set ActLine = ActiveDocument.ModelSpace.AddLine(EdgeClctn(i), EdgeClctn(1))
    Set Edges(i - 1) = ActLine
    
    'Draw Region
    ActiveDocument.ModelSpace.AddRegion (Edges)

    ' Add Solid
    Dim entLast As Entity
    Set entLast = ActiveDocument.ModelSpace.Item(ActiveDocument.ModelSpace.Count - 1)
    If entLast.EntityType = vicRegion Then
        Set reg = entLast
        Set solidObj = ActiveDocument.ModelSpace.AddExtrudedSolid(reg, 10, 0)
    End If
End Sub
Thank you!! it's works
I will figure out how to rewrite by using your code.
I truly appreciate your kindness and help.

Re: How to use the AddExtrudedSolid method?

Posted: Sat Apr 12, 2025 6:37 am
by Olivia20
The crash likely happens because regionObj(0) is invalid or AddRegion didn't create a proper region. Make sure the lines form a closed, planar loop, and add a check to confirm regionObj(0) is not Nothing before extruding. Also, try using a small taper angle like 0.01 to avoid errors . Let me know if you need a quick fix script!

Re: How to use the AddExtrudedSolid method?

Posted: Sat Apr 19, 2025 3:08 am
by polytrack
The AddExtrudedSolid method! It's a powerful tool for creating 3D geometry by sweeping a planar shape along a path. To help you use it effectively, I need a little more context. Could you tell me which software or library you are working with?

Re: How to use the AddExtrudedSolid method?

Posted: Thu Apr 24, 2025 1:33 am
by TomBrooks
The crash probably occurs because regionObj(0) is either invalid or AddRegion did not generate a valid region. Confirm that the lines create a closed, planar loop and include a check to verify that regionObj(0) is not Nothing before proceeding with the extrusion.