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: 

Modify Default Civil 3D Styles with Lisp

13 REPLIES 13
SOLVED
Reply
Message 1 of 14
alexka
2423 Views, 13 Replies

Modify Default Civil 3D Styles with Lisp

Is it possible to modify default civil 3D object styles with a lisp? My goal is to have a lisp that can change a few different default styles, but I was not able to find any code that could do this.

 

Below is an example of one style I am trying to modify:

2017-06-23 07_59_02-Edit Command Settings - CreateProfileView.png

I would like to change the default profile view style from 50h-10v LT to RT to a different style that already exists in the drawing.

 

Thanks.

13 REPLIES 13
Message 2 of 14
Jeff_M
in reply to: alexka

Yes, it's possible. Here's some code to get you started.

  (vl-load-com)
  (and (setq *acad* (vlax-get-acad-object))
       (setq C3D (strcat "HKEY_LOCAL_MACHINE\\" (if vlax-user-product-key (vlax-user-product-key) (vlax-product-key) ) )
      C3D (vl-registry-read C3D "Release")
      C3D (substr C3D 1 (vl-string-search "." C3D (+ (vl-string-search "." C3D) 1) ) )
      C3D (vla-getinterfaceobject *acad* (strcat "AeccXUiLand.AeccApplication." C3D) )      )
       (setq C3Ddoc (vla-get-activedocument C3D))
  )
(setq settings (vlax-get c3ddoc 'settings))
(setq pvcmdsettings (vlax-get settings 'profileviewcommandssettings))
(setq createpvsettings (vlax-get pvcmdsettings 'createprofileviewsettings))
(setq stylesettings (vlax-get createpvsettings 'stylesettings))
(vlax-put (vlax-get stylesettings 'style) 'value "Full Grid");;The stylename must exist!!!
Jeff_M, also a frequent Swamper
EESignature
Message 3 of 14
GTVic
in reply to: Jeff_M

<response deleted - intended for another post>

 

Message 4 of 14
hosneyalaa
in reply to: Jeff_M

HI  

 

Message 5 of 14
hosneyalaa
in reply to: hosneyalaa

التقاط0.jpg

Message 6 of 14
Jeff_M
in reply to: hosneyalaa

Yes, following the example posted previously and modifying for the desired property:

  (vl-load-com)
  (and (setq *acad* (vlax-get-acad-object))
       (setq C3D (strcat "HKEY_LOCAL_MACHINE\\" (if vlax-user-product-key (vlax-user-product-key) (vlax-product-key) ) )
      C3D (vl-registry-read C3D "Release")
      C3D (substr C3D 1 (vl-string-search "." C3D (+ (vl-string-search "." C3D) 1) ) )
      C3D (vla-getinterfaceobject *acad* (strcat "AeccXUiLand.AeccApplication." C3D) )      )
       (setq C3Ddoc (vla-get-activedocument C3D))
  )
(setq settings (vlax-get c3ddoc 'settings))
(setq pointsettings (vlax-get settings 'pointcommandssettings))
(setq pgsettings (vlax-get pointsettings 'createpointgroupsettings))
(setq stylesettings (vlax-get pgsettings 'stylesettings))
(setq style (vlax-get stylesettings 'style))
(vlax-get style 'value)
(vlax-put-property style 'value "Benchmark")
Jeff_M, also a frequent Swamper
EESignature
Message 7 of 14
hosneyalaa
in reply to: Jeff_M

Thank you very much @Jeff_M 

you are a great man
Never miss an opportunity to help others
I wish you always be healthy

I am following all your great posts
I realized that no one can help me with this request except you
Because you have a good and wide experience

Thank you very much

Message 8 of 14
hosneyalaa
in reply to: Jeff_M

HI @Jeff_M 

Depending on the code you wrote to me
I gave him a styleLabel of the pointgroup
Dependent form

Is what you wrote good or needs to be modified?
Many thanks

 

;;;    (style_styleLabel "Benchmark" "Elevation Only")
(defun style_styleLabel ( vstyle vstyleL / *ACAD* C3D C3DDOC PGSETTINGS POINTSETTINGS SETTINGS STYLESETTINGS)
(vl-load-com)
(and (setq *acad* (vlax-get-acad-object))
(setq C3D (strcat "HKEY_LOCAL_MACHINE\\" (if vlax-user-product-key (vlax-user-product-key) (vlax-product-key) ) )
C3D (vl-registry-read C3D "Release")
C3D (substr C3D 1 (vl-string-search "." C3D (+ (vl-string-search "." C3D) 1) ) )
C3D (vla-getinterfaceobject *acad* (strcat "AeccXUiLand.AeccApplication." C3D) ) )
(setq C3Ddoc (vla-get-activedocument C3D))
)
(setq settings (vlax-get c3ddoc 'settings))
(setq pointsettings (vlax-get settings 'pointcommandssettings))
(setq pgsettings (vlax-get pointsettings 'createpointgroupsettings))
(setq stylesettings (vlax-get pgsettings 'stylesettings))
(setq style (vlax-get stylesettings 'style))
(vlax-get style 'value)
(vlax-put-property style 'value vstyle)

(setq styleL (vlax-get stylesettings 'labelstyle))
(vlax-get styleL 'value)
(vlax-put-property styleL 'value vstyleL)
)

 

 

Message 9 of 14
Jeff_M
in reply to: hosneyalaa

It looks like that should work fine @hosneyalaa
Jeff_M, also a frequent Swamper
EESignature
Message 10 of 14
hosneyalaa
in reply to: Jeff_M

HI @Jeff_M 

 

https://www.theswamp.org/index.php?topic=50637.0&fbclid=IwAR1vacIXbGzIowArsR89vbA-07z3BVvNbaXwd0_1mF... (defun setsgmntlblstyle (linestyle2use arcstyle2use / *ACAD* C3D C3DDOC sgmntCMDSETS sgmntLBLSETS sgmntSTYLE SETS STYLESETS *error*) (vl-load-com) (defun *error* (msg / tmp) (if msg (princ (strcat "\n....error.... " msg)) ) (setq tmp (mapcar '(lambda (x) (vl-catch-all-apply 'vlax-release-object (list x)) ) (list sgmntCMDSETS sgmntLBLSETS sgmntSTYLE SETS STYLESETS c3ddoc c3d *acad*)) ) ) (if (and (setq *acad* (vlax-get-acad-object)) (setq C3D (strcat "HKEY_LOCAL_MACHINE\\" (if vlax-user-product-key (vlax-user-product-key) (vlax-product-key) ) ) C3D (vl-registry-read C3D "Release") C3D (substr C3D 1 (vl-string-search "." C3D (+ (vl-string-search "." C3D) 1) ) ) C3D (vla-getinterfaceobject *acad* (strcat "AeccXUiLand.AeccApplication." C3D) ) ) (setq C3Ddoc (vla-get-activedocument C3D)) ) (progn (setq sets (vlax-get c3ddoc 'settings)) (setq sgmntcmdsets (vlax-get sets 'generalcommandssettings)) (setq sgmntlblsets (vlax-get sgmntcmdsets 'AddSegmentLabelSettings ) ) (setq stylesets (vlax-get sgmntlblsets 'stylesettings)) (setq linesgmntstyle (vlax-get stylesets 'linelabelstyle)) (setq arcsgmntstyle (vlax-get stylesets 'curvelabelstyle)) (vlax-put arcsgmntstyle 'value arcstyle2use) (vlax-put linesgmntstyle 'value linestyle2use) (*error* nil) ) ) )

 

I'm sorry
Can you explain to me how to write this part of the code?
I could not arrange these lines of code. How can these words be accessed from the website I attached?

http://docs.autodesk.com/CIV3D/2012/ENU/API_Reference_Guide/com/AeccXLandLib.htm

Then the other site

http://docs.autodesk.com/CIV3D/2012/ENU/API_Reference_Guide/com/AeccXLandLib__IAeccSettingsCommandsP...

Until we get to what we want

Excuse me from
If you had a free time
And explain to me supported by pictures or video

How do we get to the sentence (vlax-get sets 'generalcommandssettings

AND
How do we get to the sentence (vlax-get sgmntcmdsets 'AddSegmentLabelSettings )


AND
How do we get to the sentence (vlax-get sgmntlblsets 'stylesettings)

AND
How do we get to the sentence (vlax-get stylesets 'linelabelstyle)
AND
How do we get to the sentence (vlax-get stylesets 'curvelabelstyle)

AND
How do we get to the sentence (vlax-put arcsgmntstyle 'value arcstyle2use)

How do we get to the sentence (vlax-put linesgmntstyle 'value linestyle2use)

 

 

Thank you very much
advance

 

 

 




Message 11 of 14
hosneyalaa
in reply to: hosneyalaa

 

How can we use this sentence as picture?
 To write the code
Thank you very much
advanceالتقاط01.PNG

Message 12 of 14
Jeff_M
in reply to: hosneyalaa

@hosneyalaa, Click the link for the ParcelLineLabels, you will get this:

2020-04-09_16-05-48.png

 

Click the Link for the property IAeccSettingAddParcelLineLabel, you will get this:

2020-04-09_16-08-10.png Click the link for the StyleSettings, then click the link in the next page for the IAecc.... property Yes, you basically need to click 2 links for each property or method you want to get to. Just keep doing this until you get to the end of the links. It's a horrible way of creating a help file, in my opinion, but once you get used to it you can usually find what you need fairly quickly.

 

I also code in the VLIDE and actually run lines of code as they get added, then use the Inspect option to see what properties are available for an object. You can drill down into them by double clicking on a property in the Inspect window. Here I set the active C3DDocument and Inspect it:

2020-04-09_16-17-43.png

then I double click each property I want to Inspect, as shown in blue in each of the windows, until I get to the final value:

2020-04-09_16-19-27.png

I hope that helps a bit.

Jeff_M, also a frequent Swamper
EESignature
Message 13 of 14
hosneyalaa
in reply to: Jeff_M

HI  Mr  Jeff_M   @Jeff_M 

Words cannot describe, thank you

Thank you very much with all my heart
For this help
And this useful and beautiful explanation

You have given so much to me and others
you are a great man
Thanks many many many
Your student Alaa

Message 14 of 14
hencoop
in reply to: Jeff_M

Nobody ever showed me how to use Inspect on Objects!  Thank you!  If I was a bit brighter I might have seen that a long time ago.  I've been inspecting using VLAX-DUMP-OBJECT (which is very tedious and not very productive).

AutoCAD User since 1989. Civil Engineering Professional since 1983
Product Ver.: 13.6.1781.0 Civil 3D 2024.3 Update
Built On:        U.152.0.0 AutoCAD 2024.1.2
                        27.0.37.14 Autodesk AutoCAD Map 3D 2024.0.1
                        8.6.52.0 AutoCAD Architecture 2024

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

Post to forums  

Rail Community


 

Autodesk Design & Make Report