Modify Civil 3D Pipe Style Display Settings with Lisp

Modify Civil 3D Pipe Style Display Settings with Lisp

alexka
Advocate Advocate
1,865 Views
8 Replies
Message 1 of 9

Modify Civil 3D Pipe Style Display Settings with Lisp

alexka
Advocate
Advocate

I'm trying to write a lisp that would change the Pipe Centerline layer and color as shown below.

 

2017-10-21 10_54_13-Pipe Style - WATR- N.png

 

I tried a vlax-dump-object on the style, but I don't know how to find the correct syntax when the "indexed contents not shown"

 

vlax-dump-object.png

 

Has anyone seen a lisp that accomplishing something similar to this, or does someone know how I can find the correct syntax for the non-vla-objects?

 

Thanks.

0 Likes
Accepted solutions (1)
1,866 Views
8 Replies
Replies (8)
Message 2 of 9

hippe013
Advisor
Advisor

To get an item that is indexed use the following:

 

(vlax-get-property style1 'DisplayStylePlan i)

***Where "i" is an integer index beginning at zero***

 

Though I am thinking that what you are trying to do is not possible or "not exposed?". I was doing some testing but I was coming up with invalid pointers.

Message 3 of 9

alexka
Advocate
Advocate
Accepted solution

Thanks @hippe013. That got me going in the right direction. Below is what I came up with. It modifies the layer and color of the plan pipe centerline display. Color 256 is bylayer.

 

(defun getpipeapp  (/ c3d verstring prodstring)
 (setq c3d        (strcat "HKEY_LOCAL_MACHINE\\"
                          (if vlax-user-product-key
                           (vlax-user-product-key)
                           (vlax-product-key)))
       c3d        (vl-registry-read c3d "Release")
       verstring  (substr c3d 1 (vl-string-search "." c3d (+ (vl-string-search "." c3d) 1)))
       prodstring (strcat "AeccXUiPipe.AeccPipeApplication." verstring))
 (if (setq c3d (vla-getinterfaceobject (vlax-get-acad-object) prodstring))
  c3d
  nil))

(defun c:WaterPipeStylePlan (/)
(setq style0 (vlax-get (vla-get-activedocument (getpipeapp)) 'pipestyles))
(setq style1 (vlax-get-property style0 'item "WATR- N"))
(setq style2 (vlax-get-property style1 'DisplayStylePlan 0))
(vlax-put style2 'color "256")
(vlax-put style2 'layer "C-WATR-PIPE-N")
)

Thanks again for your help.

0 Likes
Message 4 of 9

jtshumpert
Enthusiast
Enthusiast

What if you want to select a certain pipe and change that pipe style?

Ex: If pipe style is set to show a proposed style and you want to change it to an existing style.

 

JTS
0 Likes
Message 5 of 9

alexka
Advocate
Advocate

@jtshumpert,

 

If all you want to do is modify the style of a pipe, you can do that through the properties drop-down given that the pipe style already exists within the drawing as shown below: 

 

2019-04-05_8-18-16.jpg

 

I don't think a lisp routine would make this easier. Let me know if I'm not understanding what you're trying to do correctly.

0 Likes
Message 6 of 9

jtshumpert
Enthusiast
Enthusiast

I Know how to do that, but what to streamline the selection to one button on toolbar, pick one for exist, pick one for proposed...

JTS
0 Likes
Message 7 of 9

BlackBox_
Advisor
Advisor

@jtshumpert wrote:

I Know how to do that, but what to streamline the selection to one button on toolbar, pick one for exist, pick one for proposed...


 

I had to use .NET API to create custom LispFunction for that.

 

Cheers

 

 


"How we think determines what we do, and what we do determines what we get."

Chris Bradley (aka BlackBox)
Managing Partner / Developer / Civil Designer
Quux Software | Sincpac C3D | Style Explorer

0 Likes
Message 8 of 9

Jeff_M
Consultant
Consultant

To expand on why @BlackBox_ had to resort to .NET... trying to set the pipe's style in lisp, even though you can successfully get a style to set it to, throws an error. There are 2 ways to try to set a property, (vlax-put pipe 'style newstyle) or (vlax-put-property pipe 'style newstyle) and both throw errors:

error: ActiveX Server returned an error: Bad variable type

error: ActiveX Server returned an error: Type mismatch

 

 

Jeff_M, also a frequent Swamper
EESignature
0 Likes
Message 9 of 9

BlackBox_
Advisor
Advisor

@Jeff_M is correct; for whatever reason, the Style Property for a Part (Structure or Pipe) in LISP is exposed (not listed as read-only), but is clearly not implemented given the exceptions raised as a result of attempting to set that Property.

 

So, I rolled my own, which allows me to quickly 'sync' any Part (without the lag of synchronizing them all) or to change a Part's Style as I need using this snippet in .NET API (C#):

 

                            if (styles.Contains(styleName))
                                part.StyleId = styles[styleName];
                            else
                                ed.WriteMessage("\n; error: Style not found ");

 

Cheers


"How we think determines what we do, and what we do determines what we get."

Chris Bradley (aka BlackBox)
Managing Partner / Developer / Civil Designer
Quux Software | Sincpac C3D | Style Explorer

0 Likes