.dvb is loaded 2 times

.dvb is loaded 2 times

Anonymous
Not applicable
632 Views
6 Replies
Message 1 of 7

.dvb is loaded 2 times

Anonymous
Not applicable
i made alable.dvb to run this from menu i did this.

1) in nishdoc.lsp(is loaded at startup) i wrote
(defun c:alable ()
(command "-vbarun""alable.dvb!ThisDrawing.arealable"))

2) in nish.mnu i wrote
ID_Alable [&Alable]^C^CAlable

problem-----when i run alable from menu, command line ask same thing twice .may be because it is loaded 2 times....

Command: Alable _.-VBARUN
Macro name: alable.dvb!ThisDrawing.arealable
Alable, by Nishchay Bhuta
Specify first corner point: nil
Alable, by Nishchay Bhuta
Specify first corner point:

how to cure it?

another thing is that after initialising the command alable.dvb is loaded permanently in vba manager.is that any method to unload automatically?
0 Likes
633 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable
Hi,

You can't load the program twice. Step through your code with the F8 key
and you will probably find that you have identical prompts for the two
corners.

Unless the program is so huge that it impacts on your available memory, it's
really not worthwhile trying to unload it. If you want to use it again in
the same work session, you'll save time by having it already loaded from a
previous use.

--

Laurie Comerford
CADApps
www.cadapps.com.au
www.civil3Dtools.com
wrote in message news:5450841@discussion.autodesk.com...
i made alable.dvb to run this from menu i did this.

1) in nishdoc.lsp(is loaded at startup) i wrote
(defun c:alable ()
(command "-vbarun""alable.dvb!ThisDrawing.arealable"))

2) in nish.mnu i wrote
ID_Alable [&Alable]^C^CAlable

problem-----when i run alable from menu, command line ask same thing twice
.may be because it is loaded 2 times....

Command: Alable _.-VBARUN
Macro name: alable.dvb!ThisDrawing.arealable
Alable, by Nishchay Bhuta
Specify first corner point: nil
Alable, by Nishchay Bhuta
Specify first corner point:

how to cure it?

another thing is that after initialising the command alable.dvb is loaded
permanently in vba manager.is that any method to unload automatically?
0 Likes
Message 3 of 7

Anonymous
Not applicable
thanx laurie
my second problem is solved.but i think nothing is wrong with my code.when i run it from visual basic editor it works ok.any way i give u my code.pl suggest

Public Sub arealable()
Dim startPt As Variant
Dim endPt As Variant
Dim prompt1 As String
Dim prompt2 As String
Dim prompt3 As String
Dim prompt4 As String


''get current unitmode
umode = ThisDrawing.GetVariable("UNITMODE")

'' Get the first point without entering a base point
prompt1 = vbCrLf & "Alable, by Nishchay Bhuta" + vbCrLf & "Specify first corner point: "
startPt = ThisDrawing.Utility.GetPoint(, prompt1)

'' Use the point entered above as the base point
prompt2 = vbCrLf & "Specify second corner point: "
endPt = ThisDrawing.Utility.GetPoint(, prompt2)

'' ask for area lable
prompt3 = vbCrLf & "Enter first line of area lable: "
prompt4 = vbCrLf & "Enter next line of area lable/to finish : "
Dim alable1 As String
alable1 = ThisDrawing.Utility.GetString(True, prompt3)
Dim alable2(1 To 1) As String
For n = 1 To 1
alable2(n) = ThisDrawing.Utility.GetString(True, prompt4)
If alable2(n) = "" Then Exit For
Next

'' ask for level
prompt5 = vbCrLf & "Specify level/to finish : "
Dim level As String
level = ThisDrawing.Utility.GetString(True, prompt5)

'' calculate distance bet. two points
Dim hordiff As Double
hordiff = startPt(0) - endPt(0)
Dim verdiff As Double
verdiff = startPt(1) - endPt(1)

'' convert distances in to positive value
hordiff = Abs(hordiff)
verdiff = Abs(verdiff)

'' set unitmode value to 1
ThisDrawing.SetVariable "UNITMODE", 1

'' Convert the distance and area to current dwg units
Dim horunit As String
Dim verunit As String
precision = ThisDrawing.GetVariable("LUPREC")
horunit = ThisDrawing.Utility.RealToString(hordiff, acDefaultUnits, precision)
verunit = ThisDrawing.Utility.RealToString(verdiff, acDefaultUnits, precision)

'' create mtext
Dim text As AcadMText
Dim insertpoint(0 To 2) As Double
Dim textstring As String
insertpoint(0) = 0
insertpoint(1) = 0
insertpoint(2) = 0
textstring = "" & alable1 & "" + vbCrLf

For x = 1 To n - 1
textstring = textstring + alable2(x) + "" + vbCrLf
Next

textstring = textstring + "" & horunit & "X" & verunit & ""
textstringlvl = "\LLvl. " & level & ""

If level = "" Then
textstring = textstring
Else
textstring = textstring + vbCrLf & textstringlvl
End If

Set text = ThisDrawing.ModelSpace.AddMText(insertpoint, 0, textstring)
text.AttachmentPoint = acAttachmentPointMiddleCenter

''change insertion point to centre
Dim newinsertpoint(0 To 2) As Double
newinsertpoint(0) = (startPt(0) + endPt(0)) / 2
newinsertpoint(1) = (startPt(1) + endPt(1)) / 2
newinsertpoint(2) = 0
text.InsertionPoint = newinsertpoint

'' set unitmode value back to current
ThisDrawing.SetVariable "UNITMODE", umode

End Sub
0 Likes
Message 4 of 7

Anonymous
Not applicable
thanx laurie
my second problem is solved.but i think nothing is wrong with my code.when i run it from visual basic editor it works ok.any way i give u my code.pl suggest
also see there is "nil" automatically written in sirst prompt but not in second prompt in command line

Alable, by Nishchay Bhuta
Specify first corner point: nil
Alable, by Nishchay Bhuta
Specify first corner point:
0 Likes
Message 5 of 7

Anonymous
Not applicable
I believe prob is with
VbcrLf
vbCrLf = Chr(13) + Chr(10)
Carriage return–linefeed combination
it is returing "nil" value.
0 Likes
Message 6 of 7

Anonymous
Not applicable
prompt3 = vbCrLf & "Enter first line of area lable: "
prompt4 = vbCrLf & "Enter next line of area lable/to finish : "

change it to


prompt3 = "Enter first line of area lable: "
prompt4 = "Enter next line of area lable/to finish : "
0 Likes
Message 7 of 7

Anonymous
Not applicable
Sorry My mistake


here is example which will help u to solve the problem

Sub Example_GetPoint()
' This example returns a point entered by the user.

Dim returnPnt As Variant

' Return a point using a prompt
returnPnt = ThisDrawing.Utility.GetPoint(, "Enter a point: ")
MsgBox "The WCS of the point is: " & returnPnt(0) & ", " & returnPnt(1) & ", " & returnPnt(2) & vbCrLf & _
"(Enter the next value without prompting.)", , "GetPoint Example"

' Return a point, no prompt
returnPnt = ThisDrawing.Utility.GetPoint
MsgBox "The WCS of the point is: " & returnPnt(0) & ", " & returnPnt(1) & ", " & returnPnt(2), , "GetPoint Example"

' Return a point using a base point and a prompt
Dim basePnt(0 To 2) As Double
basePnt(0) = 2#: basePnt(1) = 2#: basePnt(2) = 0#
returnPnt = ThisDrawing.Utility.GetPoint(basePnt, "Enter a point: ")
MsgBox "The WCS of the point is: " & returnPnt(0) & ", " & returnPnt(1) & ", " & returnPnt(2)

' Create a line from the base point and the last point entered
Dim lineObj As AcadLine
Set lineObj = ThisDrawing.ModelSpace.AddLine(basePnt, returnPnt)
ZoomAll

End Sub
0 Likes