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

Example VBA code - SurveySample questions and issues

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
CharlesRheault6717
869 Views, 5 Replies

Example VBA code - SurveySample questions and issues

I am trying to modify the subject code and am having problems. I also see things that raise a number of questions.

One issue is my code to change the Marker Style in a Figure Style throws a run time error. In the function declared by CreateFigureStyle(sStylename As String) As AeccSurveyFigureStyle, I added the following code in a With oFigureStyle block:
        .FigureLinesDisplayStylePlan.Layer = "V-SURV-FIGR"
        .FigureLinesDisplayStylePlan.Linetype = "BYLAYER"
        .AdditionalMarkerStyle.Name = "Survey Sideshot"
The first two work, the third is where the error is generated. The default marker style name is "Basic". As I work on this I have allowed it to modify the style created on the first run and discovered if I edit the style manually to make it "Survey Sideshot" (no quotes) when I rerun the code it does not throw the error.

Screenshot - 1_26_2014 , 10_02_49 AM.png

I even tried changing the name in the Locals window, but the same error occured. In fact, once it is named "Survey Sideshot", I cannot change it back to "Basic" in code or the VBA IDE. I can only change it in the dialog box within the Prospector.

What am I doing wrong?

 

Also to set the marker syle layer. the code in the example is:

        .AdditionalMarkersDisplayStyle2d.color = acByLayer ' example code used blue
but the object properties list

  • AdditionalMarkersDisplayStyleModel
  • AdditionalMarkersDisplayStylePlan
  • AdditionalMarkersDisplayStyleProfile

as the properties, not AdditionalMarkersDisplayStyle2d

 

What's up with that?

 

Thanks for any guidance you can offer.

AKA CaddCop
Tags (1)
5 REPLIES 5
Message 2 of 6
Jeff_M
in reply to: CharlesRheault6717

Which version of C3D are you coding for?
Jeff_M, also a frequent Swamper
EESignature
Message 3 of 6
CharlesRheault6717
in reply to: Jeff_M

Working on home use - 2011. At work, will be 2013 when ready for use.

AKA CaddCop
Message 4 of 6
Jeff_M
in reply to: CharlesRheault6717

OK, thanks. The VBA code was originally written for C3D2007 or 2008. Back then the Display Styles were named with 2d and 3d, which have since been changed to Plan and Model. The old names still work to support any older code but since they have been deprecated they no longer show up in the Intellisense. The code ahs not been updated since 2009 due to .NET being the favored customization platform now (VBA development was dropped by MS, plus VBA in a 64 bit environment is horribly slow).

 

The error, I believe, is coming from trying to change the name of the Marker style. What you want to do, I think, is set the Marker style to use the "Survey Sideshot" style, correct? Well you will need to get the style first and pass that to 

     .AdditionalMarkerStyle = Markerstyle

 

The way you've written is to change the current marker style's name to "Survey Sideshot", but that style already exists so it errors.

Jeff_M, also a frequent Swamper
EESignature
Message 5 of 6

Hi,

 

In general while dealing with styles, you should always check if the style already exists in the current DWG file before you add / remove or assign a style to avoid this sort of issues.

 

Cheers,

Partha



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

Message 6 of 6

I tried to get the existing marker style, from the existing styles which worked. But an attempt to use

        .AdditionalMarkerStyle = oPointMarkerStyle
throws a new error.

Screenshot - 1_27_2014 , 7_23_11 AM.png

I am trying to create in code a survey style and assign some settings using existing styles. As soon as you create a style in memory, it has default settings and you have to re-assign them to another setting if the default settings do not fit your needs. Since I cannot find a place to define the default settings, I have to change the settings that are assigned by default. The problem seems to be with any and all Marker styles.

I added these declarations to the CreateFigureStyle function in the SurveySample.dvb

    Set oPointMarkerStyles = g_oAeccDatabase.MarkerStyles
    Set oPointMarkerStyle = g_oAeccDatabase.MarkerStyles.Item("Survey Sideshot")
These correcly load all styles and then find SurveySideshot in the styles

Then my line of code to attempt to assign the Survey Sideshot which throws this messages error is:

        .AdditionalMarkerStyle = oPointMarkerStyle
I also tried

        .AdditionalMarkerStyle.Name = oPointMarkerStyle.Name
which restores my original error.

 

Update!!!

I modified the code to:

      Set  .AdditionalMarkerStyle = oPointMarkerStyle

and it worked.

So Jeff_M gets the Sollution after all.

AKA CaddCop

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

Post to forums  

Rail Community


 

Autodesk Design & Make Report