Verify Whether Civil 3d Point Style Exists

Verify Whether Civil 3d Point Style Exists

jason.kreger
Explorer Explorer
411 Views
2 Replies
Message 1 of 3

Verify Whether Civil 3d Point Style Exists

jason.kreger
Explorer
Explorer

I am writing a LISP to convert all point styles in a Civil 3D drawing from a fixed-scale format to a drawing scale format.  The LISP addresses each point style in the drawing and applies a specific size to the point style based on our CAD standards.  For the most part, it works very well.  I'm only running into problems when the LISP encounters a point style that should be in the drawing, but isn't.  (e.g. the style was deleted sometime after the drawing was created from the template.)  So, I believe I need to write some logic to determine if the point style exists in the drawing before executing the three lines of code that modify the style.  I am able to access the point styles VLA-OBJECT (#<VLA-OBJECT IAeccPointStyles 000002590c8d67e0> ) and I am able to modify an 'item within that object by calling it out directly.  I just can't figure out how to have the LISP verify whether or not the point style exists and write if/then logic around it.  Thanks in advance if you're able to help.  Here's a snip of the code I'm using:  

(defun getlandapp  (/ 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 "AeccXUiLand.AeccApplication." verstring))
	(if (setq c3d (vla-getinterfaceobject (vlax-get-acad-object) prodstring))
		c3d
	nil)
)



		(setq PtStyles (vlax-get (vla-get-activedocument (getlandapp)) 'pointstyles))
		;;;want to insert logic here to say "If style "ACON" exists, then modify values, if not, skip skip to next style below";;;
		(setq ptACON (vlax-get-property PtStyles 'item "ACON"));get the Point Style
		(vlax-put-property ptACON 'MarkerSize (/ 0.12 12));set the size
		(setq ptACON nil)
		;
		(setq ptATNA (vlax-get-property PtStyles 'item "ATNA"));get the Point Style
		(vlax-put-property ptATNA 'MarkerSize (/ 0.12 12));set the size
		(setq ptATNA nil)

 

0 Likes
Accepted solutions (1)
412 Views
2 Replies
Replies (2)
Message 2 of 3

CodeDing
Advisor
Advisor
Accepted solution

@jason.kreger ,

 

Here, this is a good example for you! 

My *docC3D* variable is this object in your code:

(vla-get-activedocument (getlandapp))

Example:

(defun c:TEST ( / pointStyles pointStyle)
  (setq pointStyles (vlax-get *docC3D* 'PointStyles))
  (if (vl-catch-all-error-p
        (setq pointStyle
          (vl-catch-all-apply 'vlax-get-property (list pointStyles 'Item "MY POINT STYLE NAME"))
        )
      )
    (prompt "\nYour Point Style does not exist!")
  ;else
    (prompt "\nYour Point Style was successfully found!")
  )
  (princ)
)

Best,

~DD

0 Likes
Message 3 of 3

jason.kreger
Explorer
Explorer

@CodeDing - thank you for your response!  I shall give this a try tomorrow.  I'll be sure to credit you with a solution after testing!  😊   Thanks again!

0 Likes