Navigating C3D API - Assigning Values to Variables within Styles

Navigating C3D API - Assigning Values to Variables within Styles

brian
Explorer Explorer
356 Views
3 Replies
Message 1 of 4

Navigating C3D API - Assigning Values to Variables within Styles

brian
Explorer
Explorer

I've been working on a routine to help adjust the text height (hopefully someday more fields as needed) of Civil 3D Note Label through direct edits of the Note Label Style. The goal of this routine is to grab a number of note labels, and for each label, get it's corresponding style and adjust the text height field of the style (basically a bulk edit). 

 

I received some great help with the bulk of the code from this forum and tried to expand on it but still feel as if I'm missing how to reference various interfaces for these styles. Below, if I remove lines 14-18, the code functions as intended except dragged components retain their original text height. Looking around in the API I thought I would understand how to map to the draggedcomponentstyle and adjust the 'textheight' field (see images below) but I receive this error saying I have a bad argument type. 

brian_2-1697728542897.png

 

The program seems to recognize the interface object but I don't know if I have a problem with my text height argument (input, name, etc.) or something else. Any help with debugging my bad argument type would be appreciated. I apologize too as I'm still very new to the lisp routines. 

 

 

(defun c:test (/ th ss i lbl style txtcomponents dcs)
    (setq th (getreal "Enter Paperspace Height (inches): ") ) ;; ext Height 'th' for paper space
    (if (setq ss (ssget "_:R" '((0 . "AECC_GENERAL_NOTE_LABEL"))))
        (progn
            (setq i 0)
            (while (setq ent (ssname ss i))
                (setq lbl (vlax-ename->vla-object ent))
                (setq style (vlax-get lbl 'labelstyle)
                    txtcomponents (vlax-get style 'textcomponents)
                )
                (vlax-for comp txtcomponents
                    (vlax-put comp 'height (/ th 12)) ;; Plotted height based on user input
                )
                (setq style (vlax-get lbl 'labelstyle)
                    dcs (vlax-get style 'draggedcomponentstyle)
                )
                (vlax-for com dcs
                    (vlax-put com 'textheight (/ th 12)) ;; Plotted height based on user input
                )
                (setq i (1+ i))
            )
        )
    )
  (princ)
  )

 

 

brian_1-1697728108591.png

Img 1 - Label Style

brian_0-1697727973451.png

Img 2 - Dragged Component Style

0 Likes
357 Views
3 Replies
Replies (3)
Message 2 of 4

Jeff_M
Consultant
Consultant

Try this. The DraggedState TextHeight cannot be set if the style is set to As Composed so I added a check for that.

(defun c:test (/ th ss i lbl style txtcomponents dcs)
    (setq th (getreal "Enter Paperspace Height (inches): ") ) ;; ext Height 'th' for paper space
    (if (setq ss (ssget "_:R" '((0 . "AECC_GENERAL_NOTE_LABEL"))))
        (progn
            (setq i 0)
            (while (setq ent (ssname ss i))
                (setq lbl (vlax-ename->vla-object ent))
                (setq style (vlax-get lbl 'labelstyle)
                    txtcomponents (vlax-get style 'textcomponents)
                )
                (vlax-for comp txtcomponents
                    (vlax-put comp 'height (/ th 12)) ;; Plotted height based on user input
                )
	      (setq dcs (vlax-get style 'draggedcomponentstyle))
	      (if (= (vlax-get (vlax-get dcs 'stacktext) 'value) -1) ;;can't set the textheight if dragged state is As Composed
                (vlax-put dcs 'textheight (/ th 12)) ;; Plotted height based on user input
		)
                (setq i (1+ i))
            )
        )
    )
  (princ)
  )
Jeff_M, also a frequent Swamper
EESignature
Message 3 of 4

CogoCody
Enthusiast
Enthusiast

Thank you for that! I realize I posted that on a different account. That did work in fact. I'll have to keep an eye on that in the future if the field conflict with other display modes.

0 Likes
Message 4 of 4

Jeff_M
Consultant
Consultant

@CogoCody one other thing to note is that you had a foreach on the dcs, the dcs does not have sub-objects, it is just one object.

Jeff_M, also a frequent Swamper
EESignature
0 Likes