Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

get tracking point

7 REPLIES 7
Reply
Message 1 of 8
andresep82
465 Views, 7 Replies

get tracking point

 

Hello again!!!

 

 

 I am Making an application that inserts blocks in points,It works well but when I select a tracking point, the block is inserted in the point of reference of the tracking, and i  would like that it was inserted in thetracking point

 

how i am fix it?

 

sorry for my english level.

 

thanks¡¡¡

7 REPLIES 7
Message 2 of 8
dbroad
in reply to: andresep82

Show your code.  Do you mean "at point entities" rather than "in points."

Architect, Registered NC, VA, SC, & GA.
Message 3 of 8
andresep82
in reply to: dbroad

the code:

 

 

(defun C:PUERTAS()

;;;;;CREO LAS CAPAS POR SI NO EXISTEN;;;;;

  (if (not (tblsearch "LAYER" "CARPINTERIA"))
    (command "_.-layer" "_make" "CARPINTERIA" "_color" 2 "" "")
  )
  (if (not (tblsearch "LAYER" "CARPINTERIA_ETIQUETAS"))
    (command "_.-layer" "_make" "CARPINTERIA_ETIQUETAS" "_color" 2 "" "")

)
  
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(setvar 'clayer "CARPINTERIA"); CAMBIAR A LA CAPA



 ;;;--- Load the dcl file from disk into memory
  (if(not(setq dcl_id (load_dialog "PUERTAS.dcl")))
    (progn
      (alert "The DCL file could not be loaded!")
      (exit)
    )

    ;;;--- Else, the DCL file was loaded
    (progn

      ;;;--- Load the definition inside the DCL file
      (if (not(new_dialog "PUERTAS" dcl_id))
        (progn
        (alert "The prueba definition could not be loaded!")
          (exit)
        )
   
        ;;;--- Else, the definition was loaded 



        (progn

          ;;;--- If an action event occurs, do this function



(defun saveVars()

  ;;;--- Get the value of each item
  (setq choice1(atoi(get_tile "but1")))  ; 0 = not chosen    1 = chosen  
  (setq choice2(atoi(get_tile "but2")))  ; 0 = not chosen    1 = chosen
  (setq choice3(atoi(get_tile "but3")))  ; 0 = not chosen    1 = chosen
  
)


          
	(action_tile "accept" "(saveVars)(done_dialog 2)")
        (action_tile "cancel" "(done_dialog 1)")

	

          ;;;--- Display the dialog box
          (setq ddiag(start_dialog))

          ;;;--- Unload the dialog box
          (unload_dialog dcl_id)




         
         ;;;--- If the user pressed the Okay button


          (if(= ddiag 2)
            (progn
              (princ "\n Has elegido.... ")
      (cond
        ((= Choice1 1)(princ "62.5x2.03 cm"))
        ((= Choice2 1)(princ "72.5x2.03 cm"))
        ((= Choice3 1)(princ "82.5x2.03 cm"))
        
      );end if



(princ "\n P1 (Punto de inserción) P2 (dirección)")

(setq ip (getpoint "\n Punto de inserción:   "))


(if
	(= Choice1 1)
		
		
		(command "_insert" "E:/BLOQUES/PUERTA.dwg" ip "" "" pause )
		
		( valor 1)
		
		 

);end if




(if
	(= Choice2 1)
		
		(command "_insert" "E:/BLOQUES/PUERTA.dwg" ip "" "" pause )

		( valor 2)

);end if


(if
	(= Choice3 1)
		
		(command "_insert" "E:/BLOQUES/PUERTA.dwg" ip "" "" pause)

		( valor 3)

);end if







            );end progn
             
     );end cond



 ;;;--- If the user pressed the Cancel button
         
	(if(= ddiag 1)

		
            (princ "\n Saliendo de puertas...")
          );end if
		

        )
      )
    )
  )



(setq escalax 1)
(setq escalay 1)



(setq bloque (entlast))

		

  (setdynpropvalue (vlax-ename->vla-object bloque) "ANCHO" valor)
	
                               

  ;;;--- Suppress the last echo for a clean exit
  (princ)
)

;;;;; pasar de radianes a grados;;;;;;

(DEFUN rad_sexa (radianes)
  (/  (* radianes 180.0) PI)
)




;; Set Dynamic Block Property Value  -  Lee Mac
;; Modifies the value of a Dynamic Block property (if present)
;; blk - [vla] VLA Dynamic Block Reference object
;; prp - [str] Dynamic Block property name (case-insensitive)
;; val - [any] New value for property
;; Returns: [any] New value if successful, else nil

(defun setdynpropvalue ( blk prp val )
    (setq prp (strcase prp))
    (vl-some
       '(lambda ( x )
            (if (= prp (strcase (vla-get-propertyname x)))
                (progn
                    (vla-put-value x (vlax-make-variant val (vlax-variant-type (vla-get-value x))))
                    (cond (val) (t))
                )
            )
        )
        (vlax-invoke blk 'getdynamicblockproperties)
    )
)

;; Get Dynamic Block Properties  -  Lee Mac
;; Returns an association list of Dynamic Block properties & values.
;; blk - [vla] VLA Dynamic Block Reference object
;; Returns: [lst] Association list of ((<prop> . <value>) ... )

(defun getdynprops ( blk )
    (mapcar '(lambda ( x ) (cons (vla-get-propertyname x) (vlax-get x 'value)))
        (vlax-invoke blk 'getdynamicblockproperties)
    )
)


;; Effective Block Name  -  Lee Mac
;; obj - [vla] VLA Block Reference object

(defun effectivename ( obj )
    (vlax-get-property obj
        (if (vlax-property-available-p obj 'effectivename)
            'effectivename
            'name
        )
    )
)

 

 menu code:

 

PUERTAS : dialog {

  label = "INSERTAR PUERTAS";

          : column {

	   : column {
              : text {
                key = "text1";
                 value = "Puertas"; 
              } 
	     }


 	: boxed_column {
              label = "Dimensiones:";
                  
            : radio_row {
              key = "choices";

              : radio_button {
                key = "but1";
                label = "62.5x2.03 cm";
		
              }
              : radio_button {
                key = "but2";
                label = "72.5x2.03 cm";
              }
              : radio_button {
                key = "but3";
                label = "82.5x2.03 cm";
              }
	    }

	: radio_row {
              key = "choices1";

	      : radio_button {
                key = "but4";
                label = "Personalizado";
              }
	: edit_box {
                key = "Ancho";
                label = "Ancho(cm)";
                edit_width = 5;
                value = "";
                initial_focus = true;
              }

	: edit_box {
                key = "Alto";
                label = "Alto(cm)";
                edit_width = 5;
                value = "";
                initial_focus = true;
              }

	     }
	
    
	}
	

	: boxed_column {
              label = "Referencia:";
              
	    : edit_box {
                key = "Referencia";
                label = "Referencia carpintería";
                edit_width = 5;
                value = "P1";
                initial_focus = true;
              }
   
	    }


	}

        
	

	: column {

	: button {
                key = "accept";
                label = " Aceptar ";
                is_default = true;
              }

         
              : button {
                key = "cancel";
                label = " Cancelar ";
                is_default = false;
                is_cancel = true;
		width = 5;
 		height = 1; 
              }
	}
        

}

 the block:

 

https://www.dropbox.com/s/ly5z4indjb8n6il/puerta.dwg

 

if i active reference "Nearby" work but i like selec point using trakerig reference.

 

 

and other problem......Why it does not change the variable "valor" ?

 

 

Message 4 of 8
dbroad
in reply to: andresep82

To make your code more portable, don't hard code the paths.  For example, use

(COMMAND "_insert""PUERTA" ip "" ""  pause) rather than 

(COMMAND "_insert""E:/BLOQUES/PUERTA.dwg" ip "" ""  pause)

 

In your if sequence, I assume you only want to do one choice.  If so, then use COND or if / else constructs instead of a sequence of ifs.

 

(cond

  ((= choice1 1)
   (COMMAND "_insert" "PUERTA" ip "" "" pause)
   (valor 1)
  )
 ((= choice2 1)
  (COMMAND "_insert" "PUERTA" ip "" "" pause)
  (valor 2)
 ) 
(t
(COMMAND "_insert" "PUERTA" ip "" "" pause)
(valor 3)
) );end COND

 

valor wasn't posted so anything other than choice1 fails.

 

To use tracking, enter TRK or TK before entering the first point.  Use enter to end tracking.

 

Architect, Registered NC, VA, SC, & GA.
Message 5 of 8
andresep82
in reply to: dbroad

What you want to say with "enter TRK or TK" i dont I understand you.

 

and.... i know That I have to improve the structure of the code,   Smiley Very Happy  but I am learning.

 

thanks¡¡¡¡¡¡¡¡¡¡¡¡¡

Message 6 of 8
dbroad
in reply to: andresep82

I was responding to your original post:  "... select a tracking point.."

 

In the english version of AutoCAD tracking is accomplished by entering "tk" or "trk" at a point entry prompt before picking a point.  It allows you to take a taxi cab route to your destination from a reference point.  In a foreign language, the keyword might vary.  You could always use _tk or _tra since the underscore translates english into the localized language form.

 

If this doesn't answer your question, you will need to be a lot more descriptive of what you want.

Architect, Registered NC, VA, SC, & GA.
Message 7 of 8
andresep82
in reply to: dbroad

yes¡¡¡¡ work¡¡¡¡ but......when I insert the point I have to put the command manually, there is some way of putting it automatic?

 

 

 

(princ "\n P1 (Punto de inserción) P2 (dirección)")

(setq ip (getpoint "\n Punto de inserción:   "))

(command "_tk")



 How join in one?

 

thanks¡¡¡¡

Message 8 of 8
dbroad
in reply to: andresep82

If that is what you want, I'm not sure it can be done.  The (command "_tra") will not be sent until a response from the user.  Conventional tracking depends on user entry.  You could simulate tracking by creating a getpoint loop that would end with the enter, such as

 

 

;;set orthomode on

(setq pt (getpoint "\nSelect point: "))

(while (setq ptn (getpoint pt "\nSelect next tracking point or enter to continue: "))

  (setq pt ptn)

 ;;possible turn orthomode back on but there is no way to lock it on without a sysvar reactor.

)

;;pt is final tracking point at this point

 

Architect, Registered NC, VA, SC, & GA.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost