Jump to content

Passing an argument to command doesn't work


broncos15

Recommended Posts

I had a question about passing an argument to a Civil 3D command. For some reason, I can't figure out why it won't let me pass an argument to it. What I am trying to do is add surface labels at every vertices on a feature line. The portion of my code that I can't figure out is where I actually pass the argument to the command. My code is for that portion is:

(command "._AeccAddSurfaceSpotElevLabel" SurfaceDefaultAdd ptlist "")

Where SurfaceDefault add is my default surface in the drawing (I have a code that sets it), and the ptlist is the list of points receive from the feature lines. I don't understand why the AddSurfaceSpotElevLabel command doesn't let me put an argument into it, but instead it still makes me select the surface to add the label to.

Link to comment
Share on other sites

Maybe like the pline command for a series of points from a list.

 

 

not tested

 

 

(command "._AeccAddSurfaceSpotElevLabel")
(while (= (getvar "cmdactive") 1 )
(repeat (setq x (length ptlist)) 
(command (nth (setq x (- x 1)) ptlist))
)
)
(command "")

Link to comment
Share on other sites

BigAl, so I have been messing with your code with mine and I am having 2 problems. 1) I am unsure of where to put the surface portion (which surface to add it to). This is why I add in the check and make default surface portion of the code and 2)My code just locks up (goes in an infinite loop when I try and run it. Do you know what I am doing wrong?

;;;Makes use of BigAl's code for the command portion found at
;;;http://www.cadtutor.net/forum/showthread.php?96470-Passing-an-argument-to-command-doesn-t-work
(defun c:featurelinelabelvertices (/ fl fl-pnts ss cnt *error*)
 (defun *error* (msg)
   (if (not
         (member msg '("Function cancelled" "quit / exit abort"))
       )
     (princ (strcat "\nError: " msg))
   )
   (princ)
 )
 (if (not SurfaceDefaultAdd)
   (CheckorGetSurface)
 )
 (if (setq ss (ssget '((0 . "AECC_FEATURE_LINE"))))
   (progn
     (setq cnt 0)
     (repeat (sslength ss)
       (setq fl (vlax-ename->vla-object (ssname ss cnt)))
       (setq fl-pnts (vlax-safearray->list
                       (vlax-variant-value
                         (vlax-invoke-method fl 'GetPoints 3)
                       )
                     )
       )
       (setq fl-pnts (FL:list->pntlist fl-pnts))
       (command "._AeccAddSurfaceSpotElevLabel")
       (while (= (getvar "cmdactive") 1)
         (repeat (setq x (length fl-pnts))
           (command (nth (setq x (- x 1)) fl-pnts))
         )
       )
       (command "")
     )
   )
 )
)
;;;Setting Default Surface Function
(defun CheckorGetSurface ()
 (while
   (not
     (and
(setq SurfaceDefaultAdd
       (car
  (entsel
    "\rSelect the Main Surace you want to be the default: "
  )
       )
)
(= "AECC_TIN_SURFACE"
   (cdr (assoc 0 (entget SurfaceDefaultAdd)))
)
     )
   )
 )
)
;;;This function comes from Hippe013's FLINT code
(defun FL:List->pntlist (li / newli n)
 (setq n 0)
 (repeat (/ (length li) 3)
   (setq newli (append newli
  (list (list (nth n li)
       (nth (+ n 1) li)
       (nth (+ n 2) li)
        )
  )
 )
   )
   (setq n (+ n 3))
 )
 newli
)

Edited by broncos15
I forgot code tags
Link to comment
Share on other sites

  • 1 month later...

BigAL, so I looked into your contour changing LISP routines, and it is pretty cool! So I ended up making a change to the code (I had to use the company's way of setting the default surface because there a many other routines that make use of it and I am not able to edit firm wide routines) and it kind of works, but it also takes forever and returns "Too many objects selected for INTERSECT". My new code is:

;;;Makes use of BigAl's code for the command portion found at
;;;http://www.cadtutor.net/forum/showthread.php?96470-Passing-an-argument-to-command-doesn-t-work
(defun c:featurelinelabelvertices (/ fl fl-pnts ss cnt *error*)
 (defun *error* (msg)
   (if (not
         (member msg '("Function cancelled" "quit / exit abort"))
       )
     (princ (strcat "\nError: " msg))
   )
   (princ)
 )
 (if (not SurfaceDefaultAdd)
   (CheckorGetSurface)
 )
 (if (setq ss (ssget '((0 . "AECC_FEATURE_LINE"))))
   (progn
     (setq cnt 0)
     (repeat (sslength ss)
       (setq fl (vlax-ename->vla-object (ssname ss cnt)))
       (setq fl-pnts (vlax-safearray->list
                       (vlax-variant-value
                         (vlax-invoke-method fl 'GetPoints 3)
                       )
                     )
       )
       (setq fl-pnts (FL:list->pntlist fl-pnts))
       (command "._AeccAddSurfaceSpotElevLabel" SurfaceDefaultAdd)
       (while (= (getvar "cmdactive") 1)
         (repeat (setq x (length fl-pnts))
           (command (nth (setq x (- x 1)) fl-pnts))
         )
       )
       (command "")
     )
   )
 )
)
;;;Setting Default Surface Function
(defun CheckorGetSurface ()
 (while
   (not
     (and
(setq SurfaceDefaultAdd
       (car
  (entsel
    "\rSelect the Main Surace you want to be the default: "
  )
       )
)
(= "AECC_TIN_SURFACE"
   (cdr (assoc 0 (entget SurfaceDefaultAdd)))
)
     )
   )
 )
)
;;;This function comes from Hippe013's FLINT code
(defun FL:List->pntlist (li / newli n)
 (setq n 0)
 (repeat (/ (length li) 3)
   (setq newli (append newli
  (list (list (nth n li)
       (nth (+ n 1) li)
       (nth (+ n 2) li)
        )
  )
 )
   )
   (setq n (+ n 3))
 )
 newli
)

Link to comment
Share on other sites

Whilst you can not change the Firmwide stuff why did you use not use my set default surface method it sets current and surface style. The nice thing is if you only have one then thats the deafult else the dialouge pops up asking for which, but you could remove all that and just set. Its instant.

 

Seperately did you have a go at using the toolbars by adding you contour style names to the original code. I just use it every day so much better than the toolspace. If your having problems send me a PM with a DWG.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...