Jump to content

Layer States and Xref Layer Names


DanFHiggins

Recommended Posts

I am building layer states in Civil 3d 2011 to show all discipline types either within dwg or in xref in VBA. Discipline types will be selected by user ex. V-, C-, D-.

I can get the ones local by looking at the first two characters in the layer name ex. V-Road-Edge, C-ALIN-CNTR.

The issue comes with searching for the | character in the xref layer name. ex DGWNAME|V-NODE-UTIL, Thomson|C-TINN.

Using the INSTR command does not see the character in the xref name. I need to find where in the string it resides. I am using chr(124) to match.

Any ideas would be appreciated.

Thanks

Edited by DanFHiggins
clarification of programming platform
Link to comment
Share on other sites

Welcome to CADTutor!

 

First, I'd caution you that VBA is on its way out, so you may want to consider jumping to VB.NET if you are adept at coding in VBA (especially for interacting with Civil 3D's Aecc* Objects!). If not adept at coding in VBA, then consider Visual LISP as another option.

 

As to your question, consider using the Contains, or InStr Methods, just be sure to test / set the string case using the ToUpper, or ToLower Methods accordingly.

 

Untested examples:

 

Option Explicit
Public Sub FOO()
   Dim myString as string = "Hello World!"
   Dim keyWord as string = "hello"
   If myString.ToUpper.Contains(keyWord.ToUpper) Then
       ' <-- Do somthing
   Else
       ' <-- Do something else
   End if
End Sub

 

** Note - I know the Contains Method works in .NET, I am unsure if this is the case for VBA in AutoCAD; you may need to use InStr Method. Please let me know which one works for you.

 

Hope this helps (HTH)!

Link to comment
Share on other sites

I'm glad to hear that. :D

 

Out of curiosity, and frankly for my own edification; does the Contains Method work in VBA as it does in VB.NET?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...