-
Compteur de contenus
6 374 -
Inscription
-
Dernière visite
-
Jours gagnés
30
Type de contenu
Profils
Forums
Calendrier
Blogs
Tout ce qui a été posté par Patrick_35
-
[Résolu] Lisp de modification export DWG
Patrick_35 a répondu à un(e) sujet de Giropode dans LISP et Visual LISP
Salut Pour la couleur Ducalque (cons 62 256) Pour la couleur Dubloc (cons 62 0) @+ -
[Résolu] Lisp de modification export DWG
Patrick_35 a répondu à un(e) sujet de Giropode dans LISP et Visual LISP
Salut Pour créer le filtre (setq js (ssget "x" (list (cons 8 "BA-murs") (cons 62 6)))) Et ensuite avec la commande chprop par exemple, ou mieux avec les codes dxf. @+ -
Salut Par exemple (setq fic (getfiled "Veuillez choisir une image" "" "JPG" 8)) (setq ado (vlax-create-object "ADODB.Stream")) (vlax-put ado 'type 1) (vlax-invoke ado 'open) (vlax-invoke ado 'loadfromfile fic) (vlax-put ado 'position 0) (setq res (vlax-invoke-method ado 'read -1)) (vlax-release-object ado) (vlax-safearray->list (vlax-variant-value res)) A toi de voir à quoi correspondent les valeurs Ou encore ce lisp trouvé sur theswamp ;; SS:ReadBinaryStream V2.0 ;; ;; function : Read binarystream from file(full path) by given charset , return a List or a String . ;; ;; Args: ;; file -- file name with full path , The file size must be less than amount of memory can be used for the current AUTOCAD . ;; ;; char -- charset name , it must register in your system , see the Windows registry sub-key in \\HKEY_CLASSES_ROOT\\MIME\\Database\\Charset ;; such as "unicode","ascii","us-ascii","chinese","GB2132", etc. ;; nil & "Unicode" , allways return a list like by vlisp function Read-char . ;; Oterwise , the char will be used to convert the stream into text string . ;; ;; pos -- position for start read byte , first start pos is 0 , second is 1, ;; for Bigfont-Char it maybe use two bytes , if so the second text start pos is 2 , 4 ... 2n . ;; len -- Numbits for read or readtext , if nil or beyond the size , will be set to suit Maximum value . ;; ;; Returns -- if char is nil or "Unicode" , returns a ascii code list ;after Acad2008 , The system expansion Charset beyond the 256 limit , ;; so it may return number like 18714 or -18918(after Acad2013) ,for this case , you can use (rem 18714 256) ;; or (rem (+ 256(rem -18714 256)) 256) to get the ascii code like old version . ;; if char is not nil and "Unicode" , and it's supported in your window system , returns a string . ;; ;; by GSLS(SS) 10.23-2011 ~ ;;--------------------------------------------------------------------------;; ;; Refrence : ;; adodb.stream from http://baike.baidu.com/link?url=HkCWIQo1pSmTMN76tTipNkSUR5O_s7_8ctpH_XXuo06y2qhd-TCAkCCuxDOtNi55zA5V9eTPO4fobMbeYDNjHK ;; Microsoft Data Access Components ;; from http://en.wikipedia.org/wiki/Microsoft_Data_Access_Components ;; Nonsmall's from http://bbs.mjtd.com/forum.php?mod=viewthread&tid=78782&extra=page%3D2%26filter%3Dtypeid%26typeid%3D110&page=1 ;; Michale's from http://www.theswamp.org/index.php?topic=17465.0 ;; LeeMac's from http://www.theswamp.org/index.php?topic=39814.0 ;; Highflybird's from http://www.theswamp.org/index.php?topic=36656.0 ;; this vbs can't run in my used case : ACAD2011 Win7 64Bit. ;;--------------------------------------------------------------------------;; ;; Method of Adodb.Stream object . ;; ;; Open , Close , Write , WriteText , Read , ReadText, ;; ;; Flush , CopyTo , Cancel , SkipLine, SetEOS ;; ;; Property of Adodb.Stream object . ;; ;; LineSeparator, SaveToFile, LoadFromFile , Charset , ;; ;; Size , Position , Type , State , Mode , EOS , ;; ;;--------------------------------------------------------------------------;; ;; e.g. (SS:ReadBinaryStream (findfile "gslsshp.shx") "us-ascii" 23 32) --> ;; "\032\010\000\010\000\001\000\010\000\022\000HELL\000\r\031^d\035z6q(`\000\000\000EOF" ;; (SS:ReadBinaryStream (findfile "gslsshp.shx") "Unicode" 23 4)--> '(18714 18824 18688 18824) '(-18918 -18808 -18944 -18808)--of ACAD2015 ;; (SS:ReadBinaryStream (findfile "gslsshp.shx") nil 23 4)--> '(18714 18824 18688 18824) ;; (SS:ReadBinaryStream (findfile "gslsshp.shx") "ascii" 23 4)-->"\032\010\000\010" (defun SS:ReadBinaryStream (file char pos len / adostream ret size str) ;_(setq file "gslsshp.shx" file (findfile file) char "us-ascii" pos 0 len nil) ;_(setq file "gslsshp.shx" file (findfile file) char nil pos 23 len nil) (vl-load-com) (if (and (findfile file) ;_check file exists , No rebuild file name by (findfile file) , because it maybe not you want truely . (setq adostream (vlax-create-object "ADODB.Stream")) ;_check Adodb.Stream Object created . ) (progn (setq ret (vl-catch-all-apply (function (lambda nil (vlax-put adostream (quote Type) 1) ;_Type -- The Type property is to read / write only when the current postion located ;_ at the beginning (Position 0) of stream , at other location is read-only. ;_ The default value is adTypeText. However, if the binary data was originally ;_ written in a new empty Stream, Type will be changed to adTypeBinary. ;_ *** adTypeBinary =1 adTypeText =2 *** (vlax-invoke adostream (quote Open)) ;_Open -- Stream.Open Source, Mode, OpenOptions, UserName, Password ;_ Source -- Optional. Variant value that specifies Stream data source. Source may contain ;_ an absolute URL string that points to the existing nodes of the well-known tree structure ;_ (such as courriel or file system). Use URL keyword ("URL = http://server/folder") to specify the URL. ;_ In addition, Source may also contain open the Record object reference to the object to open the Record ;_ associated with the default stream. If not specified Source, Stream will be instantiated and open, ;_ by default it is not associated with the underlying source. ;_ ;_ Mode -- Optional. ConnectModeEnum value that specifies Access Mode (for example, read / write or read-only) of the gotten Stream . ;_ The default value is adModeUnknown. If Mode is not specified, it is inherited source Stream Variant. ;_ E.G, if you open the source Record in read-only mode, then Stream will also be open by read-only mode in default case . ;_ *** adModeRead =1 adModeReadWrite =3 adModeRecursive =4194304 adModeShareDenyNone =16 adModeShareDenyRead =4 ;_ adModeShareDenyWrite =8 adModeShareExclusive =12 adModeUnknown =0 adModeWrite =2 *** ;_ ;_ OpenOptions -- Optional. StreamOpenOptionsEnum value that's default value is -1 . ;_ *** adOpenStreamAsync =1 adOpenStreamFromRecord =4 adOpenStreamUnspecified=-1 *** ;_ UserName -- Optional. String value that contains (when necessary) the identity of the user to access a Stream object. ;_ Password -- Optional. String value that contains (when required) to access a Stream object password. (vlax-invoke-method adostream (quote LoadFromFile) file) ;_LoadFromFile -- Load the contents of an existing file into the Stream, or upload the contents of the lacal file to the server . ;_ FileName can contain any UNC format valid path and name . If the specified file does not exist, a runtime error will occur. ;_ Stream object must be open before calling LoadFromFile . This method does not change the binding Stream object , ;_ it is still bound to the object specified by URL of the original open Stream . LoadFromFile overwrite the current ;_ contents of the Stream object with the data read from the file . (setq size (vlax-get adostream (quote Size))) ;_get size (if (and (numberp pos) (< 0 pos size));_check pos(position) suitable (setq pos (fix pos)) (setq pos 0)) (if (and (numberp len) (< 0 len size));_check len(length) suitable (setq len (min len (- size pos))) (setq len (- size pos))) (vlax-put adostream (quote Position) pos) ;_Position -- For read-only Stream object, If the Position value you set exceed the Size of Stream , ;_ ADO will not return an error. This does not change the size of the Stream, ;_ Stream will not change the content in any way. However, you should avoid this operation ;_ because it may produce meaningless Position value. (vlax-invoke-method adostream (quote Write) ;_overite stream contents by binary though Unicode Charset from memory . ;_Write -- Write the binary data to Stream object . method : Stream.Write Buffer ;_ Buffer -- Variant, contains a bytes safearray to be written. ;_ The specified bytes written to Stream object, are no space between eachother . ;_ Position is set to 1+ byte of the writen data . Write method does not cut off the flow of the remaining data. ;_ If you want to cut these bytes, call SetEOS. ;_ If you write more than the current EOS position, Stream's Size will increase to include the new byte, ;_ EOS will also be moved to the last byte of new Stream . (car (list (setq ret (vlax-invoke-method adostream (quote Read) ;_ Read -- Reads the specified number of bytes or whole from the Stream object and return the Variant . ;_ specified number of bytes read from binary Stream object . Variant = Stream.Read ( NumBytes ) ;_ NumBytes -- optional. default value is adReadAll . len)) ;_read binary (vlax-put adostream (quote position) 0) ;_reset position to 0 ))) ;_end new stream (if (or (null char);_check charset (and (eq (type char) (quote STR)) (eq (strcase char) "UNICODE"));_equal default (null (member char ;_(setq char "us-ascii") (vl-registry-descendents "HKEY_CLASSES_ROOT\\MIME\\Database\\Charset")) ;_check whether character set is supported in system . )) ;_dermine return ascii list or string nil ;_no rebuild ret . (setq ret (cadddr (list (vlax-put adostream (quote position) 0) (vlax-put adostream (quote type) 2) ;_set type adTypeText (vlax-put adostream (quote charset) char) ;_set char ;_ Charset -- Specifies the character set used to convert the text contents of Stream . ;_ Such as , "Unicode" , "ascii" , "iso-8859-1" ,"Windows-1252",etc. . ;_ For systems supported character set , see the Windows registry sub-key in \\HKEY_CLASSES_ROOT\\MIME\\Database\\Charset . ;_ ;_ For text Stream object , the text object is stored as Unicode. The data read from the Stream is converted by the character ;_ set of the specified Charset property. Similarly, to write the data into the Stream object, the character set is specified to Unicode . ;_ ;_ For open Stream, it's current Position shall be at the beginning of located Stream (0) , so as to set Charset. ;_ Charset only used with text Stream object (Type of adTypeText) together. If Type is adTypeBinary, this property is ignored. (vlax-invoke adostream (quote ReadText) len) ;_ReadText ;_ ReadText -- Reads the specified number of characters from a text Stream object . Method : Stream.ReadText ( NumChars ) . ;_ NumChars is Optional , Default value is adReadAll , If NumChar over the remaining number of characters in the stream, ;_ will only return the remaining characters; Sring read is not consistent with the NumChar filled to a specified length; ;_ If there is no remaining characters can be read, it will return a value of Null variant. ;_ ***ReadText not be used to read backwards. ;_ ReadText method used with text stream (Type of adTypeText=2) . For a binary stream, please use Read. (setq STR T) )))) (vlax-invoke adostream (quote close)) ;_ Close -- Close any open objects and related objects. ;_ Use the Close method to close the Connection, Record, Recordset or Stream object to release any system resources ;_ associated with it. Close object does not remove it from memory; then you can change its property settings and ;_ turn it on again. Completely remove an object from memory, please set object variable to Nothing (Visual Basic) ;_ or nil (Visual Lisp) after close object . ret)))) (vlax-release-object adostream) ;_release object (if (not (vl-catch-all-error-p ret)) ;_catch error (if str ret ;_by ReadText (if (not (vl-catch-all-error-p (setq ret (vl-catch-all-apply (function (lambda nil (vlax-safearray->list (vlax-variant-value ret))))));_transform array format . ));_catch error of Null SQL Variant . ret (prompt (strcat "\n" (vl-catch-all-error-message ret)))) ) ;_returns (prompt (strcat "\n" (vl-catch-all-error-message ret))) ;_princ error message );_if , end result deal );_progn );_if );_defun @+
-
[Résolu] Comparaison de valeurs réelles
Patrick_35 a répondu à un(e) sujet de mateus dans LISP et Visual LISP
Salut Un coup de fatigue ;) Vivement les vacances :D @+ -
Copier des propriétés dans une table d'objets
Patrick_35 a répondu à un(e) sujet de Cadiste dans AutoCAD 2014
Salut Pour faire au plus simple et comprendre Sélection d'une ligne (setq ent (entget (car (entsel)))) Longueur de la ligne (distance (cdr (assoc 10 ent)) (cdr (assoc 11 ent))) Sélection d'un bloc (setq ent (entget (car (entsel)))) Angle de rotation du bloc (conversion des radians en degrées) (* 180.0 (/ (cdr (assoc 50 ent)) pi)) @+ -
[Résolu] Comparaison de valeurs réelles
Patrick_35 a répondu à un(e) sujet de mateus dans LISP et Visual LISP
Salut (setq mavar1 50.00 mavar2 70.00 lst (mapcar 'eval '(mavar1 mavar2)) ) @+ -
convertir définition d'attribut en texte
Patrick_35 a répondu à un(e) sujet de Milène-VdG23 dans AutoCAD 2016
Salut Après une petite recherche. @+ -
Importation pour mise à jour
Patrick_35 a répondu à un(e) sujet de willy95 dans Pour aller plus loin en LISP
Salut Avec les outils de prog Api_xls ou le lisp LXL par exemple @+ Api_xls.zip Lxl-v5.02.zip -
Salut Pour accéder au 1er calque de la table des calques, tu fais (tblnext "layer" T) Pour accéder au suivant et ainsi de suite, tu fais (tblnext "layer") @+
-
Micro-Amelioration sur Routine (Presentation/Layout) SVP
Patrick_35 a répondu à un(e) sujet de lecrabe dans Routines LISP
Salut Bruno @+ -
Micro-Amelioration sur Routine (Presentation/Layout) SVP
Patrick_35 a répondu à un(e) sujet de lecrabe dans Routines LISP
Pendant que certains déguste une galette (une bonne bretonne au blé noir) et du cidre, d'autres apprécient un plateau de fruits de mer avec un bon muscadet, des crustacés et de la mayonnaise :D @+ -
Micro-Amelioration sur Routine (Presentation/Layout) SVP
Patrick_35 a répondu à un(e) sujet de lecrabe dans Routines LISP
Salut Pour mon ventre à choux ;) (defun c:dla(/ doc lay) (vl-load-com) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vla-startundomark doc) (vlax-for lay (vla-get-layouts doc) (or (equal (vla-get-activelayout doc) lay) (eq (vla-get-name lay) "Model") (vla-delete lay) ) ) (vla-endundomark doc) (princ) ) @+ -
Definition de fonctions et localisation
Patrick_35 a répondu à un(e) sujet de famaice dans Débuter en LISP
Ma réponse va être courte. La même chose que pour les variables. Une fois que tu as compris le fonctionnement des variables entre local/global , les fonctions font de même. @+ -
Definition de fonctions et localisation
Patrick_35 a répondu à un(e) sujet de famaice dans Débuter en LISP
Salut La bonne pratique est d'être le plus propre possible dans ses déclarations de variables ou de fonctions. Un sujet récurent qui est bien expliqué par (gile) @+ -
Salut le décapode Ah, si ma femme pouvait me dire la même chose :P @+
-
Salut Juste une petite correction. -- Pour selectionner tous les Blocs commencant par *X comme les blocs anonymes (*U) Extrait de l'aide @+
-
Salut Tu as aussi cette solution @+
-
Salut Il faut faire une boucle quand on veut traiter une liste (defun c:TESTCAD (/ CalqSup n) (princ "\nVersion 1.9") (setq LstCalqSup '("1FLECHEFL" "1PARCELLENFP" "1SUBDFISC" "1TROUPARCELLE" "1TROUSUBDFISC" "3BORNE" "3FOSSEMI" "3HAIENONMI" "3MURMI" "3MURNONMI" "3SUBDFISCTEX" ) n 0 ) ;_ Fin de setq (while (setq CalqSup (nth n LstCalqSup)) (if (tblsearch "layer" CalqSup) (command "-SUPCALQUE" "n" CalqSup "" "o") ) ;_ Fin de if (setq n (1+ n)) ) ;_ Fin de if (princ) ) Ou encore (mapcar '(lambda(x / a) (or (vl-catch-all-error-p (setq a (vl-catch-all-apply 'vla-item (list (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) x)))) (vla-delete a) ) ) LstCalqSup ) ps : Grillé, mais je donne quand même ma solution qui diffère un peu. pps : Pas réveillé ce matin. ma ligne de code corrigée. @+
-
Initier un champs avec un VLAX-LDATA
Patrick_35 a répondu à un(e) sujet de DenisHen dans Personnalisation, macros, DIESEL
o Salut Et pourquoi ne pas remplir le cartouche en même temps, sans utiliser les champs ? @+ -
Initier un champs avec un VLAX-LDATA
Patrick_35 a répondu à un(e) sujet de DenisHen dans Personnalisation, macros, DIESEL
Tu as mal lu ma réponse. J'ai cité "ma_variable" dans le bout de code et dans le choix de la variable. @+ -
Initier un champs avec un VLAX-LDATA
Patrick_35 a répondu à un(e) sujet de DenisHen dans Personnalisation, macros, DIESEL
Salut (setq ma_variable (vlax-ldata-get "ERDF" "NumDossierERDF")) Et ensuite : Champ --> VariableLisp --> ma_variable Mais cela suppose que le lisp est chargé à chaque dessin pour que "ma_variable" soit valable. @+ -
Oui, car c'est la 1ere valeur. Maintenant, si on veut quelque chose de plus générique (vlax-dump-object (car (vl-remove-if-not '(lambda(x)(eq (vla-get-propertyname x) "Distance1")) dyn))) @+
-
Salut (setq blo (vlax-ename->vla-object (car (entsel)))) ; Sélection du bloc --> #<VLA-OBJECT IAcadBlockReference 000000002cd2e258> (setq dyn (vlax-invoke blo 'getdynamicblockproperties)) ; Liste des propriétés dynamiques du bloc --> (#<VLA-OBJECT IAcadDynamicBlockReferenceProperty 000000002ce43db8> #<VLA-OBJECT IAcadDynamicBlockReferenceProperty 000000002ce44db8> #<VLA-OBJECT IAcadDynamicBlockReferenceProperty 000000002ce44e38> #<VLA-OBJECT IAcadDynamicBlockReferenceProperty 000000002ce44e78>) (mapcar 'vlax-dump-object dyn) ; Lister les données dynamiques du bloc @+
-
[Challenge] Suite de Fibonacci
Patrick_35 a répondu à un(e) sujet de (gile) dans Pour aller plus loin en LISP
Salut Au contraire. Plus on est de fous... Cela permet aussi d'apporter sa pierre et une autre manière de voir. Quand (gile) m'avais indiqué que je pouvais faire plus concis, à la lecture de son code, il a raison. Je n'y avais tout simplement pas pensé. Les challenges sont aussi pédagogiques et c'est en essayant de les réaliser (quel que soit son niveau) qu'on progresse lambda permet de définir une fonction anonyme. Par exemple, quand on utilise la fonction mapcar, on envoie des infos dans une autre fonction. Dans l'exemple (mapcar 'fib '(0 1 2 3 4 5 6 7 8 9)), on envoie la valeur 0 à la fonction fib, puis la valeur 1, la valeur 2, etc... Autre exemple pour ajouter + 1 à une liste --> (mapcar '1+ '(0 1 2 3 4)) Et pour finir avec le fameux lambda qui permet la fonction anonyme, par exemple ajouter + 5 à notre liste --> (mapcar '(lambda(x)(+ 5 x)) '(0 1 2 3 4)) On évite ainsi de créer une fonction spécifique et pas vraiment utile pour ajouter 5. @+ -
[Challenge] Suite de Fibonacci
Patrick_35 a répondu à un(e) sujet de (gile) dans Pour aller plus loin en LISP
En un peu plus concis (defun fib (a / b c d e) (setq b 0 c 0 d 0) (while (<= b a) (cond ((zerop B)) ((member b '(1 2)) (setq d 1)) (T (setq e c c d d (+ d e))) ) (setq b (1+ B)) ) (+ c d) ) @+ ps : maintenant, je vais regarder de plus près ta réponse sur l'autre challenge
