broncos15 Posted April 13, 2016 Share Posted April 13, 2016 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. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted April 14, 2016 Share Posted April 14, 2016 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 "") Quote Link to comment Share on other sites More sharing options...
broncos15 Posted April 14, 2016 Author Share Posted April 14, 2016 Thanks BIGAL, I'll mess around with my LISP and see if I can get it working with this. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted April 15, 2016 Share Posted April 15, 2016 ps I did test it I turned on the mesh for 1 surface and it worked. Quote Link to comment Share on other sites More sharing options...
broncos15 Posted April 18, 2016 Author Share Posted April 18, 2016 (edited) 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 April 18, 2016 by broncos15 I forgot code tags Quote Link to comment Share on other sites More sharing options...
BIGAL Posted April 19, 2016 Share Posted April 19, 2016 have a look at this code maybe for some surface setting etc http://www.cadtutor.net/forum/showthread.php?49417-Changing-CIV3d-contours-simply&highlight=contours Nice thing is you do not have to have any surface displayed as it uses a list. May need this listselect.lsp Quote Link to comment Share on other sites More sharing options...
broncos15 Posted June 2, 2016 Author Share Posted June 2, 2016 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 ) Quote Link to comment Share on other sites More sharing options...
BIGAL Posted June 3, 2016 Share Posted June 3, 2016 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.