Code Red > VB(A)
VBA newbee needing help
(1/1)
sln8458:
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: ---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
--- End code ---
In the module above is the code:
--- Code: --- Set t_SSET = SSetCreate("TEMP_SSET", 2, "DAPDRB00")
--- End code ---
And then in the Control window I have:
--- Code: ---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
--- End code ---
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.
JohnK:
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".
sln8458:
--- Quote from: JohnK 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".
--- End quote ---
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: ---SSetCreate("TEMP_SSET", 2, "DAPDRB00")
--- End code ---
and to be more specific
--- Code: ---("TEMP_SSET", 2, "DAPDRB00")
--- End code ---
Steve
JohnK:
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?
sln8458:
Here is the code adjusted for Intellicad
--- Code: ---'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
--- End code ---
If I remove the ( ' ) from
--- Code: ---' Set t_SSET = SSetCreate("TEMP_SSET", 2, "DAPDRB00")
--- End code ---
Using F8, it stops at this line, hence why I am asking :)
Navigation
[0] Message Index
Go to full version