Jump to content
DanFHiggins

Layer States and Xref Layer Names

Recommended Posts

DanFHiggins

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

Share this post


Link to post
Share on other sites
BlackBox

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)!

Share this post


Link to post
Share on other sites
DanFHiggins

This works giving you the position of the pipe ( | ) character in the string.

 

n = InStr(1, la.Name, "|", vbTextCompare)

Share this post


Link to post
Share on other sites
BlackBox

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?

Share this post


Link to post
Share on other sites
DanFHiggins

No --------

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×