AutoCAD Map 3D Forum
Welcome to Autodesk’s AutoCAD Map 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Map 3D topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

VB for CAD

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
315 Views, 5 Replies

VB for CAD

I was wondering if anyone used VB for Autocad, I have minimal VB training, but am trying to write a small program. I'm stuck on hgetting user imput, so if anyone knows what I'm doing wrong, it would be greatly appreciated if you let me know what it is. I know mt argument is bad, but I'm not sure what to do to fix it.

Here is the code:



Private Sub cmdCancel_Click()
Unload Me
End Sub

Private Sub cmdNext_Click()
frmROWOFFSET3.Show
End Sub

Private Sub cmdSelect_Click()
Dim ent As AcadEntity

Prompt = vbCrLf & "Specify line to offset: "

ent = ThisDrawing.Utility.GetEntity(getobj, basePnt, Prompt)
End Sub
5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: Anonymous

Try something like this,

Dim MyLine As AcadEntity
Dim basePnt As Variant

ThisDrawing.Utility.GetEntity MyLine, basePnt, "Select an line"


That's VB"A" code that should work.
--

Murph
The world is not FLAT so why is your GIS data?
http://map3d.wordpress.com

wrote in message news:5683407@discussion.autodesk.com...
I was wondering if anyone used VB for Autocad, I have minimal VB training,
but am trying to write a small program. I'm stuck on hgetting user imput,
so if anyone knows what I'm doing wrong, it would be greatly appreciated if
you let me know what it is. I know mt argument is bad, but I'm not sure
what to do to fix it.

Here is the code:



Private Sub cmdCancel_Click()
Unload Me
End Sub

Private Sub cmdNext_Click()
frmROWOFFSET3.Show
End Sub

Private Sub cmdSelect_Click()
Dim ent As AcadEntity

Prompt = vbCrLf & "Specify line to offset: "

ent = ThisDrawing.Utility.GetEntity(getobj, basePnt, Prompt)
End Sub
Message 3 of 6
Anonymous
in reply to: Anonymous

There are many people doing AutoCAD programming with VB/VBA. You may have
better chances to get anwsers to your future questions in
autodesk.autocad.customization.vba NG.

Here is comment on your code.

Since the UserForm in Acad is modal form (by default), meaning when form is
shown, you cannot reach Acad editor to allow user to pick something.

So, you code in cmdSelect_Clcik event handler should be like:

Private Sub cmdSelect_Click()

''Hide the UserForm to allow interactive action to Acad
Me.Hide

''Do the pick
Dim ent As AcadEntity

Prompt = vbCrLf & "Specify line to offset: "

'You need to add "Set" keyword
Set ent = ThisDrawing.Utility.GetEntity(getobj, basePnt, Prompt)

''Do something with the picked Entity

'When done, show the UserForm again
Me.Show

End Sub



wrote in message news:5683407@discussion.autodesk.com...
I was wondering if anyone used VB for Autocad, I have minimal VB training,
but am trying to write a small program. I'm stuck on hgetting user imput,
so if anyone knows what I'm doing wrong, it would be greatly appreciated if
you let me know what it is. I know mt argument is bad, but I'm not sure
what to do to fix it.

Here is the code:



Private Sub cmdCancel_Click()
Unload Me
End Sub

Private Sub cmdNext_Click()
frmROWOFFSET3.Show
End Sub

Private Sub cmdSelect_Click()
Dim ent As AcadEntity

Prompt = vbCrLf & "Specify line to offset: "

ent = ThisDrawing.Utility.GetEntity(getobj, basePnt, Prompt)
End Sub
Message 4 of 6
Anonymous
in reply to: Anonymous

Sorry, the middle line of code should have been:

ThisDrawing.Utility.getEntity ent, basePoint, Prompt


"Norman Yuan" wrote in message
news:5683489@discussion.autodesk.com...
There are many people doing AutoCAD programming with VB/VBA. You may have
better chances to get anwsers to your future questions in
autodesk.autocad.customization.vba NG.

Here is comment on your code.

Since the UserForm in Acad is modal form (by default), meaning when form is
shown, you cannot reach Acad editor to allow user to pick something.

So, you code in cmdSelect_Clcik event handler should be like:

Private Sub cmdSelect_Click()

''Hide the UserForm to allow interactive action to Acad
Me.Hide

''Do the pick
Dim ent As AcadEntity

Prompt = vbCrLf & "Specify line to offset: "

'You need to add "Set" keyword
Set ent = ThisDrawing.Utility.GetEntity(getobj, basePnt, Prompt)

''Do something with the picked Entity

'When done, show the UserForm again
Me.Show

End Sub



wrote in message news:5683407@discussion.autodesk.com...
I was wondering if anyone used VB for Autocad, I have minimal VB training,
but am trying to write a small program. I'm stuck on hgetting user imput,
so if anyone knows what I'm doing wrong, it would be greatly appreciated if
you let me know what it is. I know mt argument is bad, but I'm not sure
what to do to fix it.

Here is the code:



Private Sub cmdCancel_Click()
Unload Me
End Sub

Private Sub cmdNext_Click()
frmROWOFFSET3.Show
End Sub

Private Sub cmdSelect_Click()
Dim ent As AcadEntity

Prompt = vbCrLf & "Specify line to offset: "

ent = ThisDrawing.Utility.GetEntity(getobj, basePnt, Prompt)
End Sub
Message 5 of 6
Anonymous
in reply to: Anonymous

THanks, everyone for your help! Is there a way to get the entity selected to be forwarded to another form? What the idea is is that the user selects the entity, selects Next, then selects the amount of space to offset the object. (i.e. 33' either side, 50' either side, 12' either side) (This program is for setting up a Road Right of Way for a utilities map.
Message 6 of 6
Anonymous
in reply to: Anonymous

Here is the project so far, sorry I guess having the full project up would have helped a little more, its not finished yet, but still trying to figure out code for running the offsets, and changing the orginal selections layer.

Form 1


Private Sub cmdCancel_Click()
Unload Me
End Sub

Private Sub cmdContinue_Click()
frmROWOFFSET2.Show
End Sub

Private Sub TextBox1_Change()

End Sub

Private Sub Label1_Click()

End Sub

Form 2



Private Sub cmdCancel_Click()
Unload Me
End Sub

Private Sub cmdNext_Click()
frmROWOFFSET3.Show
End Sub

Private Sub cmdSelect_Click()
Me.Hide

'Hide the UserForm to allow interactive action to ACAD

'do the pick
Dim ent As AcadEntity
Dim BasePoint As Variant

Prompt = vbCrLf & "Specify line to offset: "

ThisDrawing.Utility.GetEntity ent, BasePoint, Prompt


Me.Show


End Sub


Form 3

Private Sub cmdCancel3_Click()
Unload Me
End Sub

Private Sub cmdFinish_Click()
Unload Me
Unload frmROWOFFSET2
Unload frmROWOFFSET
End Sub

Private Sub opt100_Click()

End Sub

Private Sub opt24_Click()

End Sub

Private Sub opt66_Click()

End Sub

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report