Page 1 of 1

VBA, can you with code editor show a 3d solid ?

Posted: Sun Jun 07, 2020 2:52 am
by JB37
Hi there,
In my opinion this IntelliCAD never let me down - I can easily draw this by manual.
Feel free comment my program because 3d shapes are not showing and yes I prefer builtin editor.

JB

Code: Select all

    Dim myDoc As IntelliCAD.Document
    Dim pt As IntelliCAD.Point
    Dim t As IntelliCAD.Text
    Dim s As IntelliCAD.Solid3D
    Dim c As Integer
    
    Set myDoc = ActiveDocument
    Set pt = Library.CreatePoint(100, 200, 0)
        
    For i = 1 To 10
        pt.y = pt.y + 125
        Set t = myDoc.ModelSpace.AddText("Hello World!", pt, 100)
        t.color.SetRGB i * 10, i * 15, i * 20
        pt.x = pt.x - 100
        
        ' How to show box?
                
        Set s = myDoc.ModelSpace.AddBox(pt, 100, 100, 100)
        s.color.SetRGB i * 10, i * 15, i * 20
        pt.x = pt.x + 100
        
    Next i
    
    ' How to clear drawing?
    ' How to show all of drawing?
    ' How to change perspective and view?
    ' How to close form?
    

Re: VBA, can you with code editor show a 3d solid ?

Posted: Sun Jun 07, 2020 5:04 am
by QuanNguyen
Hi JB,
Maybe you need to zoom extent the drawing to see the objects.
Here's the result of your code.
Box.png
Box.png (30.33 KiB) Viewed 6784 times

Code: Select all

Public Sub AddBoxEx()
    Dim myDoc As IntelliCAD.Document
    Dim pt As IntelliCAD.Point
    Dim t As IntelliCAD.text
    Dim s As IntelliCAD.Solid3D
    Dim c As Integer
    
    Set myDoc = ActiveDocument
    Set pt = Library.CreatePoint(100, 200, 0)
        
    For i = 1 To 10
        pt.y = pt.y + 125
        Set t = myDoc.ModelSpace.AddText("Hello World!", pt, 100)
        t.color.SetRGB i * 10, i * 15, i * 20
        pt.x = pt.x - 100
        
        ' How to show box?
        Set s = myDoc.ModelSpace.AddBox(pt, 100, 100, 100)
        s.color.SetRGB i * 10, i * 15, i * 20
        pt.x = pt.x + 100
        
    Next i
    
    ' zoom
    IntelliCAD.ActiveDocument.Application.ZoomExtents
    
End Sub

Re: VBA, can you with code editor show a 3d solid ?

Posted: Sun Jun 07, 2020 8:48 am
by JB37
I tried reset profile and still no boxes.
Extents command perfect thank you !

Re: VBA, can you with code editor show a 3d solid ?

Posted: Sun Jun 07, 2020 4:35 pm
by QuanNguyen
You're welcome!
And here's the code for clearing all texts in model space:

Code: Select all

Public Sub EraseAllText()
    Dim ent As Entity
    For Each ent In IntelliCAD.ActiveDocument.ModelSpace
        If ent.EntityName = "Text" Then ent.Delete
    Next    
End Sub

Re: VBA, can you with code editor show a 3d solid ?

Posted: Mon Jun 08, 2020 12:37 am
by JB37
Something like this,

Code: Select all

Public Sub clearDrawing()
    Dim ent As Entity
    With IntelliCAD.ActiveDocument
        If .ModelSpace.Count <> 0 Then
            For Each ent In .ModelSpace
                 ent.Delete
            Next
        End If
    End With
End Sub


Re: VBA, can you with code editor show a 3d solid ?

Posted: Mon Jun 08, 2020 1:39 am
by JB37
I got the solution you need plus version for 3d solids.
solid3.jpg
solid3.jpg (48.28 KiB) Viewed 6707 times