DVB file

#1
Is there a way to open/edit an acad.dvb file in intellicad?

I have been asked to have a look at running a vba add-on for Autocad in Intellicad, and I know nothing about VBA!

SteveN

Re: DVB file

#2
Hi Steven,

The DVB is used for AutoCAD, but in IntelliCAD, the VBA file is .vbi. So you cannot directly open the .dvb file in IntelliCAD.

Please load and open the DVB file in AutoCAD visual basic editor, and copy the codes from the editor (paste and save to a text file format).
Then, open the Editor of IntelliCAD and paste the code to it.

Regards,
Quan Nguyen.

Re: DVB file

#7
I have managed to export/import the Forms & Modules.
However, as expected, ALL of the sub-routines fail.

Here is an example:

Code: Select all

Sub EDIT_MakeRed()
    Dim t_SSET As AcadSelectionSet
    Dim t_Index As Integer
    Set t_SSET = ThisDrawing.SelectionSets.Add("TEMP_SSET")
    t_SSET.SelectOnScreen
    If (t_SSET.Count > 0) Then
        For t_Index = 1 To t_SSET.Count
            t_SSET.Item(t_Index - 1).Color = acRed
            Next t_Index
        End If
    Call SSetDeleteAll
End Sub
This is intended to change the colour of the selected items to colour RED
Error message:
Command: -vbarun
Macro name: DAP.EDIT_MakeRed
Macro failed
Macro failed.

I can see that there is ref to Acad, but I know nothing about VBA to make any changes.

Can anyone offer any pointers please?
SteveN

Re: DVB file

#8
Hi Steven,
You can refer to the sample code in the official document and then modify the VBA code to fixed with IntelliCAD.
VBA_AddLine.png
VBA_AddLine.png (35.69 KiB) Viewed 337 times
BTW, here is the IntelliCAD for changing the selected objects to red color.

Code: Select all

Public Sub MakeRed()
    Dim ss As SelectionSet
    Dim i As Integer
    
    For Each ss In ActiveDocument.SelectionSets
        If ss.Name = "TEMP_SSET" Then
            ss.Delete
            Exit For
        End If
    Next
    
    Set ss = ActiveDocument.SelectionSets.Add("TEMP_SSET")
    ss.SelectOnScreen
   
    If ss.Count <> 0 Then
        For i = 0 To ss.Count - 1
            ss.Item(i).color.ColorIndex = vicRed
            ss.Item(i).Update
        Next
    End If
End Sub

Re: DVB file

#10
Thanks to Quan, I now have 5 working macros:
Image
Change colour to RED, WHITE, YELLOW
Change Linetype to Continuous. Dashed.

Here is the toolbar that I am trying to get working, the icon at the right end manually loads the VBA project.
Image
.

I have started on 1 macro 'projectPagesShow' (which is the icon to the right of the yellow icon) and have the form display when selecting the toolbar icon.

SteveN

Re: DVB file

#12
Hi Quan,

That's basically what I have done on the end of the toolbar.
to load the project:

Code: Select all

 ^C^C^CFILEDIA 0 VBILOAD "E:\CustomCad\DAP\SLN.vbi" FILEDIA 1
Then for each macro:

Code: Select all

^C^C-vbarun SLN.EDIT_MakeRed 
The project loads when selected, and each macro runs fine also when selected.
All I need to do is sort the code for each macro :roll:

Yes it was a long time ago!
Tho I have a document on my desktop with links to a number of John's VBA tutorials.
Sadly John hasn't posted in a very long time.
Not sure if his tutorials could be pegged at the top of the index??

SteveN

Re: DVB file

#13
I'm struggling here with the online info and my ability to understand!! :(

Here is a module from the Acad dvb file:

Code: Select all

Sub DAP_ProjectDetailsShow()
    Dim t_SSET As AcadSelectionSet
    Dim t_Form As Variant
    
    Call SSetDeleteAll						'this is a sub module frequently used, Is it to clear any Selection set details currently retained/memory??
    
    Set t_SSET = SSetCreate("TEMP_SSET", 2, "DAPDRB00")
    If (t_SSET.Count = 1) Then
        Set t_Form = DAP_DPP					'this is the form to be displayed, which contain fields which match attributes in the drawing border DAPDRB00.DWG
        Call DynamicFormLoad(t_Form, t_SSET.Item(0).Handle)
        t_Form.show						'show/display the form
        End If
    Call SSetDeleteAll						'clear any Selection set details ????
End Sub

Does this statement create a new selection set? is it names TEMP SSET ? What is the '2' meaning
Set t_SSET = SSetCreate("TEMP_SSET", 2, "DAPDRB00")

This is what I have so far:

Code: Select all

'BORDER
Sub SLN_ProjectDetailsShow()

    Dim t As SelectionSet
    Dim t_Form As Variant
    
'    Call SSetDeleteAll
    
'    Set t_SSET = SSetCreate("TEMP_SSET", 2, "DAPDRB00")
'    Set ss = SelectionSets.Add("TEMP_SSET", 2, "DAPDRB00")
    
    If (t_SSET.Count = 1) Then
        Set t_Form = DAP_DPP
        Call DynamicFormLoad(t_Form, t_SSET.Item(0).Handle)
        t_Form.show
        End If
'    Call SSetDeleteAll
End Sub
SteveN

Re: DVB file

#14
Hi Steven,

In VBA, there're distinguish between the Sub and the Function ( in Lisp, they call the Defun too).
The difference between a function and a sub in VBA is that a function can return a value while a sub cannot.
A Sub/Function can have or doesn't have arguments, in your attached, the function SSetCreate has three arguments: the first is a string type, the second one is an integer/real type, and the last one is a string type.
For the meaning of the arguments, the user must refer to the detail of that function.

Code: Select all

Function SSetCreate(ssName As String, numberValue As Double, stringValue As String) As AcadSelectionSet
 ' do something here
End Function

Re: DVB file

#15
Sadly Quan's last answer/reply makes no sense to me :(.

However I am making some progress, albeit blindly.
So in the function I have:

Code: Select all

'BORDER
Sub SLN_ProjectDetailsShow()

    Dim t_SSET As SelectionSet
    Dim t_Form As Variant
    
    Call SSetDeleteAll
    
    Set t_SSET = SSetCreate("TEMP_SSET", 2, "DAPDRB00")
'    If (t_SSET.Count = 1) Then
        Set t_Form = DAP_DPP
'        Call DynamicFormLoad(t_Form, t_SSET.Item(0).Handle)
        t_Form.show
'        End If
    Call SSetDeleteAll
End Sub
and in a sub I have:

Code: Select all

Function SSetCreate(d_SetName As String, d_Mode As Integer, d_Data As String) As SelectionSet
    Dim t_SSET As SelectionSet
    Dim t_Point1(0 To 2) As Double
    Dim t_Point2(0 To 2) As Double
    Dim t_Code1(0) As Integer
    Dim t_Value1(0) As Variant
    Dim t_Code2 As Variant
    Dim t_Value2 As Variant
    t_Point1(0) = 0: t_Point1(1) = 0: t_Point1(2) = 0
    t_Point2(0) = 300: t_Point2(1) = 200: t_Point2(2) = 0
    t_Code1(0) = d_Mode
    t_Value1(0) = d_Data
    t_Code2 = t_Code1
    t_Value2 = t_Value1
    Set t_SSET = ActiveDocument.SelectionSets.Add(d_SetName)
    ActiveDocument.SendCommand ("zoom all" + vbCr)
    t_SSET.Select acSelectionSetAll, t_Point1, t_Point2, t_Code2, t_Value2		**********error here
    ActiveDocument.SendCommand ("zoom p" + vbCr)
    Set SSetCreate = t_SSET
End Function
However when using F8 to increment through the code it stops at:

Code: Select all

    t_SSET.Select acSelectionSetAll, t_Point1, t_Point2, t_Code2, t_Value2
with acSelectionSetAll highlighted and a Compile error, Variable not defined.


Online searching suggests this is an Autocad Variable name, is there an Intellicad equivalent?
SteveN