Visual Lisp - Create Collection of Surface Contour Labels

Visual Lisp - Create Collection of Surface Contour Labels

DevinLJackson
Explorer Explorer
969 Views
2 Replies
Message 1 of 3

Visual Lisp - Create Collection of Surface Contour Labels

DevinLJackson
Explorer
Explorer

Hello all! 

I am relatively new to working with lisp programming, and am working on create to lisp to toggle on and off the contour label line visibility.  I am using this code for extracting surface boundaries as a starting point, but am running into trouble when trying to loop through the collection of objects. 

 

I've tried using a selection set, I've tried converting the selection set (as in the current code at the bottom) to a vla-object but always get an error ; error: bad argument type: VLA-object collection: XXXXXX. 

I tried to create a collection similar to the example code below for surface contour labels, but couldn't find a entry  similar to the surfaces for the contour labels when inspecting the active document in VLIDE (screenshot attached). 

(setq c3ddoc (vlax-get c3d 'activedocument)
				surfs (vlax-get c3ddoc 'surfaces)


Can anyone point me in the right direction as to what am I doing wrong? 

(vl-load-com)
(DEFUN C:test ( / c3d c3ddoc all_lbls vl_lbls lbls *acad* )
;(SETQ object (vlax-ename->vla-object (CAR (ENTSEL))))
	(if (setq *acad* (vlax-get-acad-object)
		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) )
		)
 
		(progn
            (setq c3ddoc (vlax-get c3d 'activedocument))
			(setq all_lbls (ssget "x" (list (cons 0 "AECC_SURFACE_CONTOUR_LABEL_GROUP"))))
	   		(setq vl_lbls  (vlax-ename->vla-object (ssname all_lbls 0)))
			(vlax-for lbls vl_lbls
				(vlax-put-property lbls "IsLabelLineVisible" 1 )
			)
			(if (not (vlax-object-released-p c3d) ) (vlax-release-object c3d) )
			(if (not (vlax-object-released-p *acad*) ) (vlax-release-object *acad*) )
		)
	)
    (princ)
);END DEFUN

 

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

Jeff_M
Consultant
Consultant
Accepted solution

You don't need the C3D application/document for this.

(defun c:togglecontourlabellinedisplay(/ ss idx ent obj)
  (if (setq ss (ssget "X" '((0 . "AECC_SURFACE_CONTOUR_LABEL_GROUP"))))
    (progn
      (setq idx -1)
      (while (setq ent (ssname ss (setq idx (1+ idx))))
	(setq obj (vlax-ename->vla-object ent))
	(if (= -1 (vlax-get obj 'IsLabelLineVisible))
	  (vlax-put obj 'IsLabelLineVisible 0)
	  (vlax-put obj 'IsLabelLineVisible -1)
	  )
	)
      )
    )
  (princ)
  )
Jeff_M, also a frequent Swamper
EESignature
Message 3 of 3

DevinLJackson
Explorer
Explorer

Ahhhh, thanks so much Jeff! My greenness was very apparent with the active document code. I greatly appreciate you clearing that up for me. 

 

 

0 Likes