PDA

View Full Version : Dim Selected Pt



rad.77676
2005-12-28, 11:11 PM
I keep getting an error on the following code, any ideas why?
"Variable not defined" How do you dim a pt before selecting it?


Set oAECObject = ThisDrawing.Utility.GetEntity(Pt, "Select the required Object ")

Thanks,
Rob

Jeff_M
2005-12-28, 11:58 PM
Dim vPickpoint As Variant
Dim oEnt As AcadEntity

ThisDrawing.Utility.GetEntity oEnt, vPickpoint, "Select the required Object "


HTH,
Jeff

rad.77676
2005-12-29, 12:02 AM
Dim vPickpoint As Variant
Dim oEnt As AcadEntity

ThisDrawing.Utility.GetEntity oEnt, vPickpoint, "Select the required Object "


HTH,
Jeff

Jeff,
Two things, I'm not sure I want to Dim as acad entity, since I'm working with civil 3d?
the next is I get an error: Expected end of statement

Jeff_M
2005-12-29, 12:49 AM
The GetEntity method requires the use of an AcadEntity.
This code works fine for me with a AeccDbSurfaceTin Civil3D object.


Sub test()
Dim vPickpoint As Variant
Dim oEnt As AcadEntity

ThisDrawing.Utility.GetEntity oEnt, vPickpoint, "Select the required Object "
Debug.Print oEnt.ObjectName
End Sub

Could you eloborate on what you are trying to do?

jwanstaett
2005-12-29, 02:09 PM
Jeff,
Two things, I'm not sure I want to Dim as acad entity, since I'm working with civil 3d?
the next is I get an error: Expected end of statementJeff all civil 3d object that you can select with ThisDrawing.Utility.GetEntity will be acad entity

all civil 3d entity are a sub class of acad entity

rad.77676
2005-12-29, 05:29 PM
Could you eloborate on what you are trying to do?

Jeff,
What I am trying to accomplish is to create a list/xlist routine for civil 3d that will access object, layer, linetype, color, etc.... for civil objects selected directly, or through xref's.

I am a vba newbie, but I have to start somewhere right?

Here is the code I was provided, with changes I received here:



Option Explicit

Dim vPickpoint As Variant
Dim oEnt As AcadEntity

Public Sub List_Object()
Set oAECObject = ThisDrawing.Utility.GetEntity oEnt, vPickpoint, "Select the required Object "
If TypeOf oAECObject Is AECCSurface Then
Set oDTM = oAECObject
With oDTM
sName = .Name
dX = .MajorContourInterval
dY = .MinorContourInterval
End With
'MsgBox "The minor interval on surface "sName" is "dY" and the major interval is "dX"
End If
'If TypeOf is something else etc.
End Sub


oAECObject
Error Msg: Variable not defined

Thanks,
Rob

Jeff_M
2005-12-29, 06:54 PM
Jeff,
What I am trying to accomplish is to create a list/xlist routine for civil 3d that will access object, layer, linetype, color, etc.... for civil objects selected directly, or through xref's.

I am a vba newbie, but I have to start somewhere right?

Thanks,
Rob
Rob, you've decided to learn VBA with a mighty tough project. The Civil3d API is still quite new and not very refined for the novice coder. And to make it even tougher, the Help files for Developers are not very intuitive.

I would suggest, however, taking a quick course on the basics of VBA or at least reading through the standard Autocad Developer help & examples to see how things must be structured. I am far from an expert in this field, heck I only started using VBA about 2 years ago with similar goals to yours, but I know that I read far more than I coded the first few months.

None the less, here is your code modified to do exactly what you were trying to do. Note that to acheive your ultimate goal you won't be able to use the GetEntity method....objects in blocks/xfrefs can only be selected with GetSubEntity....and to make it harder, Civil3d objects cannot be individually selected with either of those....... Look in the Autodesk newsgroup (Civil3d or land-desktop customization, I don't recall which) for a solution I posted for selected a Civil3d point object for an example of this.


'Requires both of the Autodesk Civil Land libraries to be referenced
Option Explicit

Public Sub List_Object()
Dim vPickpoint As Variant
Dim oEnt As AcadEntity
Dim oDTM As AeccSurface
Dim sName As String
Dim dX, dY
Dim oSurfStyl As AeccSurfaceStyle
Dim oContStyl As AeccSurfaceContourStyle

ThisDrawing.Utility.GetEntity oEnt, vPickpoint, "Select the required Object "
If TypeOf oEnt Is AeccSurface Then
Set oDTM = oEnt
With oDTM
sName = .Name
Set oSurfStyl = .Style
'an AeccSurface does not have the following properties..... _
you will need to dig down into the Style/ContourStyle
'dX = .MajorContourInterval
'dY = .MinorContourInterval
End With
Set oContStyl = oSurfStyl.ContourStyle
dX = oContStyl.MajorContourInterval
dY = oContStyl.MinorContourInterval
MsgBox "The minor interval on surface " & sName & " is " & dY & _
" and the major interval is " & dX
End If
'If TypeOf is something else etc.
End Sub

Good Luck!
Jeff

rad.77676
2005-12-29, 07:20 PM
Rob, you've decided to learn VBA with a mighty tough project.
I would suggest, however, taking a quick course on the basics of VBA or at least reading through the standard Autocad Developer help & examples to see how things must be structured. I am far from an expert in this field, heck I only started using VBA about 2 years ago with similar goals to yours, but I know that I read far more than I coded the first few months.

None the less, here is your code modified to do exactly what you were trying to do.Good Luck!
Jeff

Jeff,
Thanks for all your help, I have in fact been through a few tutorials at this point, but as you say there isn't always a clear answer to questions that may arise.

This routine is setup to select a surface contour, how would you account for all civil objects without having to specify each possibility inside this routine?

Thanks again,
Rob

Jeff_M
2005-12-29, 07:43 PM
Jeff,
Thanks for all your help, I have in fact been through a few tutorials at this point, but as you say there isn't always a clear answer to questions that may arise.

This routine is setup to select a surface contour, how would you account for all civil objects without having to specify each possibility inside this routine?

Thanks again,
Rob
You're welcome.
As for the selecting, you will need to have a bunch of ElseIf's for every type you intend to list. I would, however, break out each object type to a seperate function to help with the readability of the main Sub. But again, some items are not directly selectable such as the aforementioned Point. Try selecting a point and you get the group it belongs to. Try selecting a contour and you get the surface. Try selecting a line in an alignment and you get the entire alignment, etc....... I have not used C3D enough to know how all of the objects are inter-related so I can't help much more than this until I can fool around a bit more with it.

One other suggestion, I think you will get far more help with Civil3d type questions over in the autodesk.aec.land-desktop.customization newsgroup. I know it was for LDD but others have started to use it for Civil3d, too, and I know that one of the Autodesk programmers (Peter Funk) stops by with code help from time to time.

Again, Good Luck!

rad.77676
2005-12-29, 07:46 PM
One other suggestion, I think you will get far more help with Civil3d type questions over in the autodesk.aec.land-desktop.customization newsgroup. I know it was for LDD but others have started to use it for Civil3d, too, and I know that one of the Autodesk programmers (Peter Funk) stops by with code help from time to time.

Again, Good Luck!

Thanks again,
I'll check this out!
Rob

rad.77676
2006-01-10, 05:27 PM
Note that to acheive your ultimate goal you won't be able to use the GetEntity method....objects in blocks/xfrefs can only be selected with GetSubEntity....and to make it harder, Civil3d objects cannot be individually selected with either of those....... Look in the Autodesk newsgroup (Civil3d or land-desktop customization, I don't recall which) for a solution I posted for selected a Civil3d point object for an example of this.


Jeff,
Is it possible, once you've selected the civil3d object using GetEntity to dive further into the object using the GetSubEntity to select the block and/or xref.
I wasn't able to find your post about the civil3d point.
Thanks,
Rob

Jeff_M
2006-01-10, 07:26 PM
Jeff,
Is it possible, once you've selected the civil3d object using GetEntity to dive further into the object using the GetSubEntity to select the block and/or xref.
Not that I'm aware of.

I wasn't able to find your post about the civil3d point.
Thanks,
Rob
http://discussion.autodesk.com/thread.jspa?threadID=446068

HTH,
Jeff