Author Topic: VBA newbee needing help  (Read 8707 times)

0 Members and 1 Guest are viewing this topic.

sln8458

  • Newt
  • Posts: 91
  • CMS Intellicad 9.0/10.0
VBA newbee needing help
« on: October 17, 2022, 10:08:26 AM »
Hi all,

A little background to my problem first.

One of my customers passed on my details to another of their clients as someone who could help with their Acad issues. This client is a PLC engineer who knows nothing about CAD as such and does not want to. He runs Acad2000 on an old XP laptop. The first problem was he had lost his toolbars, one of which is a custom toolbar explicitly to run a number of VBA macros. I managed to sort this out after a little while (I last used Acad with Release 14!). After this was sorted he explained that he was worried that his XP laptop would die and he would be lost.
I use Intellicad 11, which some may know is 'similar' to Acad.

Anyway he asked would I look at porting his VBA into Intellicad.

So here I am looking at VBA for the first time!! (in hindsight I should have refused, but too late now)

My current problem:
The following macro is called from one of the buttons in the custom toolbar. I loads a custom for to allow editing of the drawing border attributes.
Code: [Select]
Sub DAP_ProjectDetailsShow()
    Dim t_SSET As AcadSelectionSet
    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

In the module above is the code:
Code: [Select]
      Set t_SSET = SSetCreate("TEMP_SSET", 2, "DAPDRB00")
And then in the Control window I have:

Code: [Select]
Function SSetCreate(d_SetName As String, d_Mode As Integer, d_Data As String) As AcadSelectionSet
    Dim t_SSET As AcadSelectionSet
    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 = ThisDrawing.SelectionSets.Add(d_SetName)
    ThisDrawing.SendCommand ("zoom all" + vbCr)
    t_SSET.Select acSelectionSetAll, t_Point1, t_Point2, t_Code2, t_Value2
    ThisDrawing.SendCommand ("zoom p" + vbCr)
    Set SSetCreate = t_SSET
End Function


In my confused mind I am struggling to understand the highlighted statement.
I think it is looking for the drawing DAPDRB00 (which is a border with attributes) in the area from:0,0,0  to:300,200,0

Could one of you more knowledgeable folk explain for me please?
SteveN.
There is no such  thing as a 'silly question' to those who do not know!

JohnK

  • Administrator
  • Seagull
  • Posts: 10605
Re: VBA newbee needing help
« Reply #1 on: October 17, 2022, 10:25:48 AM »
I haven't done VBA in years but at the 10,000 foot level; SSetCreate is a function that just creates a selection set. DAP_ProjectDetailsShow will call SSetCreate with the selection set name to create. That isn't the "inserting the block code".
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

sln8458

  • Newt
  • Posts: 91
  • CMS Intellicad 9.0/10.0
Re: VBA newbee needing help
« Reply #2 on: October 17, 2022, 10:42:13 AM »
I haven't done VBA in years but at the 10,000 foot level; SSetCreate is a function that just creates a selection set. DAP_ProjectDetailsShow will call SSetCreate with the selection set name to create. That isn't the "inserting the block code".

Hi John,
I understand that this does not insert the block, that is done via another toolbar button.
I think this looks for the block being present, in the drawing window specified, before displaying the new dialog box (form).

Using the ( ' ) at the start of each line I can get the form to display.
But I don't understand
Code: [Select]
SSetCreate("TEMP_SSET", 2, "DAPDRB00") and to be more specific
Code: [Select]
("TEMP_SSET", 2, "DAPDRB00")
Steve
There is no such  thing as a 'silly question' to those who do not know!

JohnK

  • Administrator
  • Seagull
  • Posts: 10605
Re: VBA newbee needing help
« Reply #3 on: October 17, 2022, 12:00:19 PM »
Yes, you should be correct; it is looking for a block in that area of the drawing. The block must be called "DAPDRB00".

A single quote in VB is a comment; you get the form to display if you comment out what?
 
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

sln8458

  • Newt
  • Posts: 91
  • CMS Intellicad 9.0/10.0
Re: VBA newbee needing help
« Reply #4 on: October 17, 2022, 01:07:15 PM »
Here is the code adjusted for Intellicad

Code: [Select]
'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


If I remove the ( ' ) from
Code: [Select]
'    Set t_SSET = SSetCreate("TEMP_SSET", 2, "DAPDRB00")
Using F8, it stops at this line, hence why I am asking :)
There is no such  thing as a 'silly question' to those who do not know!