TheSwamp
Code Red => VB(A) => Topic started by: Adesu on September 16, 2009, 03:26:46 AM
-
I would create a code in vba, replace old code to new code, at old code coordinate the object display at massagebox, but for new code i want displace at userform, as example i have a line from coordinate 0,0,0 to 10,5,0.
How to display coordinate start point and end point ?
here my old code
Sub sgcc()
Dim ObjEnt As AcadEntity
Dim Pt As Variant
ThisDrawing.Utility.GetEntity ObjEnt, Pt, "Pick an object"
Dim PtX As Double
Dim PtY As Double
Dim PtZ As Double
PtX = Pt(0)
PtY = Pt(1)
PtZ = Pt(2)
MsgBox "Coordinate X is = " & PtX _
& vbCr & "Coordinate X is = " & PtY _
& vbCr & "Coordinate X is = " & PtZ
End Sub
-
something like the dist Command ?
Measures the distance and angle between two points
-
Thanks for reply, I mean like this
Private Sub TextBox1_Change()
"what code for place coordinate"
End Sub
And look at attach file.
something like the dist Command ?
Measures the distance and angle between two points
-
are you wanting to type in the coords in the box or pick the entity and have it put the picked points in the box?
-
Yes that right "pick the entity and have it put the picked points in the box"
are you wanting to type in the coords in the box or pick the entity and have it put the picked points in the box?
-
Hi,
Here new code to display coordinate startpoint and endpoint of line, but sorry this still error, it display error like this "Run-time 'error 424: object requied', would you please guide me to fix it.
' ppdc is stand for Pick Line Display Coordinates
' Design by : Adesu <Ade Suharna>
' Email : adesu@tentangcad.com
' adesu@telkom.net
' abahadethea@yahoo.co.id
' Homepage : http://cadesu.multiply.com
' Create : 22 February 2010
' Program no.: 00xx/02/2010
' Edit by :
Sub pldc()
Dim objPicked As AcadLine
Dim Pt As Variant
ThisDrawing.Utility.GetEntity objPicked, Pt, "Pick an object line"
UserForm1.TextBox1.text = objPicked.StartPoint(0)
UserForm1.TextBox2.text = objPicked.StartPoint(1)
UserForm1.TextBox3.text = objPicked.StartPoint(2)
UserForm1.TextBox4.text = objPicked.EndPoint(0)
UserForm1.TextBox5.text = objPicked.EndPoint(1)
UserForm1.TextBox6.text = objPicked.EndPoint(2)
UserForm1.Show
End Sub
here code for userform
Private Sub CommandButton2_Click()
End
End Sub
Private Sub UserForm_Activate()
UserForm1.TextBox1.SetFocus
UserForm1.TextBox2.SetFocus
UserForm1.TextBox3.SetFocus
UserForm1.TextBox4.SetFocus
UserForm1.TextBox5.SetFocus
UserForm1.TextBox6.SetFocus
End Sub
Private Sub CommandButton1_Click()
objPicked.StartPoint(0) = TextBox1.Visible
objPicked.StartPoint(1) = TextBox2.Visible
objPicked.StartPoint(2) = TextBox3.Visible
objPicked.EndPoint(0) = TextBox4.Visible
objPicked.EndPoint(1) = TextBox5.Visible
objPicked.EndPoint(2) = TextBox6.Visible
End Sub
Yes that right "pick the entity and have it put the picked points in the box"
are you wanting to type in the coords in the box or pick the entity and have it put the picked points in the box?
-
The user form code will provide the Error Message "Runtime error 424: object Required" because of the following.
Private Sub CommandButton1_Click()
objPicked.StartPoint(0) = TextBox1.Visible
objPicked is not a global reference variable therefore cannot be used in this SUB, therefore error message.
Additionally, the example code provided by Adesu is attempting to set the visibility of the form controls = the startpoint and endpoint values. Not sure why this is being done, but since it is, all values will be the binary result of the .Visible for each textbox control. The example code, will be setting both the startpoint and endpoint to -1,-1,-1 and this isn't good, a line cannot have the endpoint and startpoint at the same place in space.