change autocad option profile with autolisp programmation

change autocad option profile with autolisp programmation

mduvalAA6EJ
Enthusiast Enthusiast
883 Views
3 Replies
Message 1 of 4

change autocad option profile with autolisp programmation

mduvalAA6EJ
Enthusiast
Enthusiast

hello, I am new on this site I am trying to program a "lisp" routine I do not know how to change the autocad profile with this routine depending on whether it is metric or imperial. Can you help me that would be very useful for me to continue .. I am French speaking sorry for my English

 

bonjour, je suis nouveau sur ce site je tente de programmer une routine "lisp" je ne sais pas comment changé le profile autocad avec cette routine selon que ce soit métrique ou impérial pouvez vous m'aider ca me serait tres utile pour continuer.. je suis francophone désolé pour mon anglais

 

thanks

 

see files attached

 

 

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

marko_ribar
Advisor
Advisor

I've slightly mod. it and made it prittier... Untested though... You should check profile strings you supply to (vla-put-activeprofile) function; perhaps \\ are needed instead of single \...

 

 

;;; rec_echelle
;;; routine de setup plan rochon infrastructel (écehelle - ltscale - dimstyle - textstyle)
;;; en lien avec rec_echelle.dcl
;;; version 2021-10-31
;;; créé par Martin Duval

(defun c:rec_profile nil
  (vl-load-com)
  (cond
    ( (= INFO 1)
      (vla-put-ActiveProfile (vla-get-Profiles (vla-get-Preferences (vlax-get-acad-object))) "AutoCAD MEP \(US Metric\)")
    )
    ( (= INFO 2)
      (vla-put-ActiveProfile (vla-get-Profiles (vla-get-Preferences (vlax-get-acad-object))) "AutoCAD MEP \(US Imperial\)")
    )
  )
)

(defun c:rec_echelle ( / dcl_id w h LT userclick )
  (setq dcl_id (load_dialog "C:/Users/mduval/OneDrive - Rochon Experts Conseils inc/_normes_REC/rec_echelle.dcl"))		
  (if (not (new_dialog "rec_echelle" dcl_id));not
    (exit)
  );if
  (setq w (dimx_tile "im")	
        h (dimy_tile "im")	
  );setq
  (start_image "im")	
  (slide_image 0 0 w h "C:/Users/mduval/OneDrive - Rochon Experts Conseils inc/_normes_REC/logo_rochon.sld")
  ;(fill_image 0 0 w h 5)
  (end_image)

  (action_tile "1M" "(setq INFO 1)")
  (action_tile "0i" "(setq INFO 2)")

  (action_tile "1000" "(setq LT 8000)")
  (action_tile "750" "(setq LT 6000)")	
  (action_tile "500" "(setq LT 4000)")
  (action_tile "400" "(setq LT 3200)")	
  (action_tile "300" "(setq LT 2400)")
  (action_tile "250" "(setq LT 2000)")
  (action_tile "200" "(setq LT 1600)")
  (action_tile "150" "(setq LT 1200)")
  (action_tile "125" "(setq LT 1000)")	
  (action_tile "100" "(setq LT 800)")	
  (action_tile "75" "(setq LT 600)")	
  (action_tile "50" "(setq LT 400)")	
  (action_tile "25" "(setq LT 200)")	
  (action_tile "10" "(setq LT 80)")
  (action_tile "5" "(setq LT 40)")
  (action_tile "1" "(setq LT 8)")
  (action_tile "768i" "(setq LT 241.92)")
  (action_tile "384i" "(setq LT 120.96)")
  (action_tile "192i" "(setq LT 60.48)")
  (action_tile "96i" "(setq LT 30.24)")
  (action_tile "64i" "(setq LT 20.16)")
  (action_tile "48i" "(setq LT 15.12)")
  (action_tile "32i" "(setq LT 10.08)")
  (action_tile "24i" "(setq LT 7.56)")	
  (action_tile "19.2i" "(setq LT 6.048)")
  (action_tile "16i" "(setq LT 5.04)")	
  (action_tile "12i" "(setq LT 3.78)")
  (action_tile "1i" "(setq LT 0.315)")

  (action_tile
    "cancel"						
    "(done_dialog) (setq userclick nil)"		
  );action_tile

  (action_tile
    "accept"						
    "(done_dialog) (setq userclick T)"			
  );action tile

  (start_dialog)					
  (unload_dialog dcl_id)				

  (command "_.-dimstyle" "_r" "Annotative_REC")
  (command "_.-dimstyle" "_r" "Annotative_REC-met")
  (command "_.textstyle" "Annotative")
  (command "_.ltscale" LT "")

  (c:rec_profile)

  (setq CANNOSCALE LT)
  (cond
    ( (= LT 8000) (setvar "CANNOSCALE" "1:1000") )
    ( (= LT 6000) (setvar "CANNOSCALE" "1:750") )
    ( (= LT 4000) (setvar "CANNOSCALE" "1:500") )
    ( (= LT 2400) (setvar "CANNOSCALE" "1:300") )
    ( (= LT 3200) (setvar "CANNOSCALE" "1:400") )
    ( (= LT 2000) (setvar "CANNOSCALE" "1:250") )
    ( (= LT 1600) (setvar "CANNOSCALE" "1:200") )
    ( (= LT 1200) (setvar "CANNOSCALE" "1:150") )
    ( (= LT 1000) (setvar "CANNOSCALE" "1:125") )
    ( (= LT 800) (setvar "CANNOSCALE" "1:100") )
    ( (= LT 600) (setvar "CANNOSCALE" "1:75") )
    ( (= LT 400) (setvar "CANNOSCALE" "1:50") )
    ( (= LT 200) (setvar "CANNOSCALE" "1:25") )
    ( (= LT 80) (setvar "CANNOSCALE" "1:10") )
    ( (= LT 40) (setvar "CANNOSCALE" "1:5") )
    ( (= LT  (setvar "CANNOSCALE" "1:1") )
    ( (= LT 241.92) (setvar "CANNOSCALE" "1/64\" = 1'-0\"") )
    ( (= LT 120.96) (setvar "CANNOSCALE" "1/32\" = 1'-0\"") )
    ( (= LT 60.48) (setvar "CANNOSCALE" "1/16\" = 1'-0\"") )
    ( (= LT 30.24) (setvar "CANNOSCALE" "1/8\" = 1'-0\"") )
    ( (= LT 20.16) (setvar "CANNOSCALE" "3/16\" = 1'-0\"") )
    ( (= LT 15.12) (setvar "CANNOSCALE" "1/4\" = 1'-0\"") )
    ( (= LT 10.08) (setvar "CANNOSCALE" "3/8\" = 1'-0\"") )
    ( (= LT 7.56) (setvar "CANNOSCALE" "1/2\" = 1'-0\"") )
    ( (= LT 6.048) (setvar "CANNOSCALE" "5/8\" = 1'-0\"") )
    ( (= LT 5.04) (setvar "CANNOSCALE" "3/4\" = 1'-0\"") )
    ( (= LT 3.78) (setvar "CANNOSCALE" "1\" = 1'-0\"") )
    ( (= LT 0.315) (setvar "CANNOSCALE" "1:1") )
  )
  (prompt "\nVariable INFO is global... To use it type REC_PROFILE at command prompt... To clear memory, type (setq INFO nil), or if you want to change value of INFO, restart main routine - type REC_ECHELLE at command prompt...")
  (princ "\n")
  (princ userclick)
  (princ)
)

 

 

 

rec_echelle : dialog { //dialog name
        label = "Echelle principale" ; //give it a label
: row { //define row
//// INFO SYSTEM UNITE
: boxed_radio_column { //define radio column
        label = "systeme d'unite" ; //give it a label
: radio_button { //define radion button
        key = "1M" ; //give it a name
        label = "metrique" ; //give it a label
  } //*end definition
} //*end radio column
: boxed_radio_column { //define radio column
: radio_button { //define radion button
        key = "0i" ; //give it a name
        label = "imperial" ; //give it a label
  } //*end definition
} //*end radio column
} //end row
: row { //define row
//// colonne métrique
: boxed_radio_column { //define radio column
        label = "Metrique" ; //give it a label
: radio_button { //define radion button
        key = "1000" ; //give it a name
        label = "1:1000" ; //give it a label
        } //end definition
: radio_button { //define radion button
        key = "750" ; //give it a name
        label = "1:750" ; //give it a label
        } //end definition
: radio_button { //define radion button
        key = "500" ; //give it a name
        label = "1:500" ; //give it a label
        } //end definition
: radio_button { //define radion button
        key = "400" ; //give it a name
        label = "1:400" ; //give it a label
        } //end definition
: radio_button { //define radion button
        key = "300" ; //give it a name
        label = "1:300" ; //give it a label
        } //end definition
: radio_button { //define radion button
        key = "250" ; //give it a name
        label = "1:250" ; //give it a label
        } //end definition
: radio_button { //define radion button
        key = "150" ; //give it a name
        label = "1:150" ; //give it a label
        } //end definition
: radio_button { //define radion button
        key = "125" ; //give it a name
        label = "1:125" ; //give it a label
        } //end definition
: radio_button { //define radion button
        key = "100" ; //give it a name
        label = "1:100" ; //give it a label
        } //end definition
: radio_button { //define radion button
        key = "75" ; //give it a name
        label = "1:75" ; //give it a label
        } //end definition
: radio_button { //define radion button
        key = "50" ; //give it a name
        label = "1:50" ; //give it a label
        } //end definition
: radio_button { //define radion button
        key = "25" ; //give it a name
        label = "1:25" ; //give it a label
        } //end definition
: radio_button { //define radion button
        key = "20" ; //give it a name
        label = "1:20" ; //give it a label
        } //end definition
: radio_button { //define radion button
        key = "10" ; //give it a name
        label = "1:10" ; //give it a label
        } //end definition
: radio_button { //define radion button
        key = "5" ; //give it a name
        label = "1:5" ; //give it a label
        } //end definition
: radio_button { //define radion button
        key = "1" ; //give it a name
        label = "1:1" ; //give it a label
      ///  value = "1" ; //switch it on
        } //end definition
        } //end radio column
///// impérial
: boxed_radio_column { //define radio column
       label = "Imperial" ; //give it a label
: radio_button { //define radion button
        key = "768i" ; //give it a name
        label = "1\/64\" = 1'-0\"" ; //give it a label
        } //end definition     
: radio_button { //define radion button
        key = "384i" ; //give it a name
        label = "1\/32\" = 1'-0\"" ; //give it a label
        } //end definition    
: radio_button { //define radion button
        key = "192i" ; //give it a name
        label = "1\/16\" = 1'-0\"" ; //give it a label
        } //end definition
: radio_button { //define radion button
        key = "96i" ; //give it a name
        label = "1\/8\" = 1'-0\"" ; //give it a label
        } //end definition
: radio_button { //define radion button
        key = "64i" ; //give it a name
        label = "3\/16\" = 1'-0\"" ; //give it a label
        } //end definition
: radio_button { //define radion button
        key = "48i" ; //give it a name
        label = "1\/4\" = 1'-0\"" ; //give it a label
        } //end definition
: radio_button { //define radion button
        key = "32i" ; //give it a name
        label = "3\/8\" = 1'-0\"" ; //give it a label
        } //end definition
: radio_button { //define radion button
        key = "24i" ; //give it a name
        label = "1\/2\" = 1'-0\"" ; //give it a label
        } //end definition
: radio_button { //define radion button
        key = "19.2i" ; //give it a name
        label = "5\/8\" = 1'-0\"" ; //give it a label
        } //end definition
: radio_button { //define radion button
        key = "16i" ; //give it a name
        label = "3\/4\" = 1'-0\"" ; //give it a label
        } //end definition
: radio_button { //define radion button
        key = "12i" ; //give it a name
        label = "1\" = 1'-0\"" ; //give it a label
        } //end definition
: radio_button { //define radion button
        key = "1i" ; //give it a name
        label = "12\" = 1'-0\"" ; //give it a label
        } //end definition
        } //end radio column
} //end row
ok_cancel ; //predifined OK/Cancel
: row { //define row
: image { //define image tile
key = "im" ; //give it a name
height = 8.0 ; //and a height
width = 24.0 ; //and now a width
} //end image
: paragraph { //define paragraph
: text_part { //define text
label = "standard" ; //give it some text
} //end text
: text_part { //define more text
label = "Rochon Infrastructel 2021" ; //some more text
} //end text
} //end paragraph
} //end row
} //end dialog

 

 

HTH.

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 3 of 4

mduvalAA6EJ
Enthusiast
Enthusiast

Hi Marko, if I understand your message correctly it is to replace \ by \\ (translated from English) it did not work then what I did is rename the profiles by "1" and "2" in the lisp and autocad and it doesn't work anymore .. I don't know how I found these lines on another post from another website it's visual lisp I think ...... thanks for the modification is very appreciated ...

 

salut Marko, si je comprend bien ton message c'est de remplacer \ par \\ (traduit de l'anglais) cela n'a pas fonctionné alors ce que j'ai fait c'est renommer les profil par "1" et "2" dans le lisp et autocad et ca ne fonctionne pas plus .. je ne sais pas comment faire j'ai trouvé ces lignes sur un autre post d'un autre site internet c'est du visual lisp je pense......merci pour la modification c'est tres apprécié ...

0 Likes
Message 4 of 4

mduvalAA6EJ
Enthusiast
Enthusiast
;;; rec_echelle
;;; routine de setup plan rochon infrastructel (écehelle - ltscale - dimstyle - textstyle)
;;; en lien avec rec_echelle.dcl
;;; version 2021-10-31
;;; créé par Martin Duval

(defun c:rec_profile nil
  (vl-load-com)
  (cond
    ( (= INFO 1)
      (vla-put-ActiveProfile (vla-get-Profiles (vla-get-Preferences (vlax-get-acad-object))) "AutoCAD MEP \(US Metric\)")
    )
    ( (= INFO 2)
      (vla-put-ActiveProfile (vla-get-Profiles (vla-get-Preferences (vlax-get-acad-object))) "AutoCAD MEP \(US Imperial\)")
    )
  )
)

(defun c:rec_echelle ( / dcl_id w h LT userclick )
  (setq dcl_id (load_dialog "C:/Users/mduval/OneDrive - Rochon Experts Conseils inc/_normes_REC/rec_echelle.dcl"))		
  (if (not (new_dialog "rec_echelle" dcl_id));not
    (exit)
  );if
  (setq w (dimx_tile "im")	
        h (dimy_tile "im")	
  );setq
  (start_image "im")	
  (slide_image 0 0 w h "C:/Users/mduval/OneDrive - Rochon Experts Conseils inc/_normes_REC/logo_rochon.sld")
  ;(fill_image 0 0 w h 5)
  (end_image)

  (action_tile "1M" "(setq INFO 1)")
  (action_tile "0i" "(setq INFO 2)")

  (action_tile "1000" "(setq LT 8000)")
  (action_tile "750" "(setq LT 6000)")	
  (action_tile "500" "(setq LT 4000)")
  (action_tile "400" "(setq LT 3200)")	
  (action_tile "300" "(setq LT 2400)")
  (action_tile "250" "(setq LT 2000)")
  (action_tile "200" "(setq LT 1600)")
  (action_tile "150" "(setq LT 1200)")
  (action_tile "125" "(setq LT 1000)")	
  (action_tile "100" "(setq LT 800)")	
  (action_tile "75" "(setq LT 600)")	
  (action_tile "50" "(setq LT 400)")	
  (action_tile "25" "(setq LT 200)")	
  (action_tile "10" "(setq LT 80)")
  (action_tile "5" "(setq LT 40)")
  (action_tile "1" "(setq LT 8)")
  (action_tile "768i" "(setq LT 241.92)")
  (action_tile "384i" "(setq LT 120.96)")
  (action_tile "192i" "(setq LT 60.48)")
  (action_tile "96i" "(setq LT 30.24)")
  (action_tile "64i" "(setq LT 20.16)")
  (action_tile "48i" "(setq LT 15.12)")
  (action_tile "32i" "(setq LT 10.08)")
  (action_tile "24i" "(setq LT 7.56)")	
  (action_tile "19.2i" "(setq LT 6.048)")
  (action_tile "16i" "(setq LT 5.04)")	
  (action_tile "12i" "(setq LT 3.78)")
  (action_tile "1i" "(setq LT 0.315)")

  (action_tile
    "cancel"						
    "(done_dialog) (setq userclick nil)"		
  );action_tile

  (action_tile
    "accept"						
    "(done_dialog) (setq userclick T)"			
  );action tile

  (start_dialog)					
  (unload_dialog dcl_id)				

  (command "_.-dimstyle" "_r" "Annotative_REC")
  (command "_.-dimstyle" "_r" "Annotative_REC-met")
  (command "_.textstyle" "Annotative")
  (command "_.ltscale" LT "")

  (c:rec_profile)

  (setq CANNOSCALE LT)
  (cond
    ( (= LT 8000) (setvar "CANNOSCALE" "1:1000") )
    ( (= LT 6000) (setvar "CANNOSCALE" "1:750") )
    ( (= LT 4000) (setvar "CANNOSCALE" "1:500") )
    ( (= LT 2400) (setvar "CANNOSCALE" "1:300") )
    ( (= LT 3200) (setvar "CANNOSCALE" "1:400") )
    ( (= LT 2000) (setvar "CANNOSCALE" "1:250") )
    ( (= LT 1600) (setvar "CANNOSCALE" "1:200") )
    ( (= LT 1200) (setvar "CANNOSCALE" "1:150") )
    ( (= LT 1000) (setvar "CANNOSCALE" "1:125") )
    ( (= LT 800) (setvar "CANNOSCALE" "1:100") )
    ( (= LT 600) (setvar "CANNOSCALE" "1:75") )
    ( (= LT 400) (setvar "CANNOSCALE" "1:50") )
    ( (= LT 200) (setvar "CANNOSCALE" "1:25") )
    ( (= LT 80) (setvar "CANNOSCALE" "1:10") )
    ( (= LT 40) (setvar "CANNOSCALE" "1:5") )
    ( (= LT 8) (setvar "CANNOSCALE" "1:1") )
    ( (= LT 241.92) (setvar "CANNOSCALE" "1/64\" = 1'-0\"") )
    ( (= LT 120.96) (setvar "CANNOSCALE" "1/32\" = 1'-0\"") )
    ( (= LT 60.48) (setvar "CANNOSCALE" "1/16\" = 1'-0\"") )
    ( (= LT 30.24) (setvar "CANNOSCALE" "1/8\" = 1'-0\"") )
    ( (= LT 20.16) (setvar "CANNOSCALE" "3/16\" = 1'-0\"") )
    ( (= LT 15.12) (setvar "CANNOSCALE" "1/4\" = 1'-0\"") )
    ( (= LT 10.08) (setvar "CANNOSCALE" "3/8\" = 1'-0\"") )
    ( (= LT 7.56) (setvar "CANNOSCALE" "1/2\" = 1'-0\"") )
    ( (= LT 6.048) (setvar "CANNOSCALE" "5/8\" = 1'-0\"") )
    ( (= LT 5.04) (setvar "CANNOSCALE" "3/4\" = 1'-0\"") )
    ( (= LT 3.78) (setvar "CANNOSCALE" "1\" = 1'-0\"") )
    ( (= LT 0.315) (setvar "CANNOSCALE" "1:1") )
  )
  (prompt "\nVariable INFO is global... To use it type REC_PROFILE at command prompt... To clear memory, type (setq INFO nil), or if you want to change value of INFO, restart main routine - type REC_ECHELLE at command prompt...")
  (princ "\n")
  (princ userclick)
  (princ)
)
0 Likes