Jump to content

Help: add total length in dynamic blocks


Romero

Recommended Posts

First of all, I want to thank each of the users that with their great help I have been able to learn a little about Lisp.

I hope and some of you can help me with this code to add the total length of dynamic blocks that have a stretch parameter.

Basically the code works well; asks the user to enter the name of the parameter and then performs its function.

There is a problem: if I select other dynamic blocks that have another parameter by name, it does not work; I would like to be able to solve that problem. Any ideas?

I would also like it to be repeated multiple times and that the previous user's entry be saved for the name of the parameter.

I hope it's not too much to ask. From Mexico I thank you very much, and I apologize for my English, which is not very good. I will be very grateful if someone can help me.

 

;Suma en bloques dinamicos: Indicando el nombre del parametro
;Solo seleccionar bloques dynamicos que tengan ese parametro


(vl-load-com)

(defun c:SUMBD
      (/ total selectionset count intger selectionsetname obj AR)
 
 (setq AR (getstring t "\nNOMBRE PARAMETRO: "))

(defun LM:getdynpropvalue ( blk prp )
   (setq prp (strcase prp))
   (vl-some '(lambda ( x ) (if (= prp (strcase (vla-get-propertyname x))) (vlax-get x 'value)))
     (vlax-invoke blk 'getdynamicblockproperties)
     )
   )
 
 (if (setq total 0
    selectionset
     (ssget '((0 . "INSERT")
	      (-4 . "<or")
	      (2 . "`*U*")
	      (2 . "_P1000")
	      (-4 . "or>")
	      )
	    )
    )
   (progn
     (setq count (sslength selectionset))
     (repeat (setq intger (sslength selectionset))
(setq selectionsetname
       (ssname selectionset
	       (setq intger (1- intger))
	       )
      obj (vlax-ename->vla-object selectionsetname)
      total (+ total
	       (LM:getdynpropvalue obj AR)
	       )))
     (alert (strcat " CANTIDAD TOTAL DE BLOQUES DYNAMICOS :"
	     "< "
	     (itoa count)
	     " >"
	     "\n"
	     " LONGITUD TOTAL EN BLOQUES DYNAMICOS :"
	     "< "
	     (rtos total 2)
	     " >"
	     )
     )
     )
   (princ)
   )
 (princ)
)

Link to comment
Share on other sites

Basically the code works well; asks the user to enter the name of the parameter and then performs its function.

There is a problem: if I select other dynamic blocks that have another parameter by name, it does not work; I would like to be able to solve that problem. Any ideas?

 

Hi,

 

The following should give you a push forward. ;)

 

(if (setq total 0
         selectionset (ssget '((0 . "INSERT")(2 . "`*U*,_P1000"))))
   (progn
     (setq count (sslength selectionset))
     (repeat (setq intger (sslength selectionset))
(setq selectionsetname (ssname selectionset (setq intger (1- intger))))
       (if (= (vla-get-EffectiveName (vlax-ename->vla-object selectionsetname)) "_P1000")
         ( ;; ..............

Link to comment
Share on other sites

The following should give you a push forward.

 

Thank you very much Tharwat for your appreciable help.

 

Analyze the code and try to solve the routine. I thank you very much and thank you for taking part of your time to help.

Link to comment
Share on other sites

  • 2 years later...

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...