Lee Mac 发表于 2022-7-6 06:42:32

Please study the following example carefully:

(defun c:essai ( / col enx pt1 pt2 )   ;; Define function, declare local variable symbols.   ;; To understand why variable declaration is important,   ;; see http://lee-mac.com/localising.html   (if ;; If the following expression returns a non-nil value       (and         ;; All of the supplied expressions must return a non-nil         ;; value for AND to return T. AND will cease evaluating         ;; expressions when an expression returns nil, or when         ;; all expressions have been evaluated.                      (setq pt1 (getpoint "\n1st Point: "))         ;; Prompt user for 1st point         ;; e.g. pt1 = (123.0 456.0 0.0)         (setq pt2 (getpoint "\n2nd Point: " pt1))         ;; Prompt user for 2nd point, rubber-band to 1st point         ;; e.g. pt2 = (567.0 789.0 0.0)                  ) ;; end AND       (progn         ;; Evaluate the following expressions and return the result         ;; of the last expression evaluated. PROGN is used as a         ;; wrapper function so that we can pass multiple expressions         ;; to the IF function as a single argument constituting the         ;; 'then' parameter.                      (command "_.pline" "_non" pt1 "_non" pt2 "")         ;; Invoke the PLINE command         ;; Command prefix meanings:         ;; "_"   = use the English version of the command/keyword         ;; "."   = use a non-redefined version of the command         ;; "non" = Object Snap modifier equal to "None" to ignore Object Snap for the next point                      (setq enx (entget (entlast)))         ;; Retrieve the DXF data of the last entity added to the drawing database         ;; More error trapping is potentially required here to ensure that the         ;; LWPolyline was created successfully and is indeed the last entity         ;; added to the drawing database, but I shall omit this to retain the         ;; simplicity of this example.         ;; e.g. enx = ((0 . "LWPOLYLINE") (5 . "ABC") (90 . 2) (70 . 0) ... )                      (if (setq col (assoc 62 enx))               ;; If the DXF data contains DXF group 62, assign this pair to the local variable 'col'               ;; Entities with colour set to ByLayer will not contain a DXF group 62 pair.               ;; e.g. col = (62 . 3) or col = nil                              (entmod (subst '(62 . 2) col enx))               ;; If DXF group 62 is present, i.e. 'col' is non-nil,               ;; substitute the DXF group 62 pair for a new pair within the               ;; DXF data, and use ENTMOD to update the DXF data in the drawing database.                              (entmod (append enx '((62 . 2))))               ;; Else, the entity colour was set to ByLayer and 'col' = nil               ;; so append a new DXF group 62 pair to the DXF data and use               ;; ENTMOD to update the DXF data for the entity in the drawing database.                        ) ;; end IF                  ) ;; end PROGN          ) ;; end IF      (princ) ;; Supress the return of the last evaluated expression   ) ;; end DEFUN

mathieucraveiro 发表于 2022-7-6 06:46:28

Thank You Lee Mac !!!really really good explained, nothing to tell.

Lee Mac 发表于 2022-7-6 06:49:50

Excellent, I'm glad my explanations were comprehensible.
You're very welcome Mathieu.

mathieucraveiro 发表于 2022-7-6 06:52:48

Hello everybody, i come back in this post because , i would like to have a possibility to get back every name's block "assistant" in my drawing to erase it. How i can to do? And if i'ts possible to have some explanation of every details about this function "ssget" because i don't understand for example : "_+.:E:S" there it's that i can find in a french post but i don't understand. Thank you

mathieucraveiro 发表于 2022-7-6 06:56:21

Hello , it's fine i have just find the code to get back my "assistant" blocks. It was to erase it. you can see by thejoin picture "assistant", my blocks on continuation of the polylign but that it's just a litle help for the user choose which side he wants to have these lightings. Actually the polylign it's thelighting network. After this part, i'm blocked to get back each litle "polylign" who represent the jonction betwen the main network and lightings when you can show in the join picture " explanations".
 
I hope you will understand because i know it's long and maybe i don't use the good word to explain me. So tell me if you are not understand something. I continue my program by steps and there i'm blocked to get back my entities
 
Below the actually code who permit to draw the jonction betwen the main network and my lightings.
 

(defun DECAL_CANDE (/ rep n pt3) ;;rappel : red: en haut ;;           blue: en bas (initget "red blue") (setq        rep (getkword   "\n which side want to put your lightings? : " ) ) (setq jsBlock (ssget "_A" (list '(0 . "INSERT") '(2 . "assistant")))) (command "_erase" jsBlock "") ; there i tell at the program to erase my "assistant" blocks to draw the jonction. (if (or (eq rep "red") (eq rep "R") (eq rep "")); if theanswer is red we draw on this side   (progn                                ;draw in the red side   (foreach n lst_pt ; lst_pt contain the list with each point of insert lighting blocks, (variable set in other code) (setq pt3 (polar n (+ orient (/ pi 2)) decalageCandelabre) ; "decalageCandelabre" is the distance betwen the main network and the lighting      pt4 (polar n (+ orient pi) (/ decalageCandelabre 2))      pt5 (polar n (+ orient 0) (/ decalageCandelabre 2)))(command "polylign" n pt3 "")        ; i have to get back entitie(command "polylign" n pt4 "")        ; i have to get back entitie(command "polylign" pt4 pt3 "")        ; i have to get back entitie(command "polylign" n pt5 "")        ; i have to get back entitie(command "polylign" pt5 pt3 "")        ; i have to get back entitie   (command "inserer" ; this command it's for insert the lightings blocks but it doesn't work for the moment       "C:/pgn_mat/Blocs/candelabre3.dwg"       n       1       1       (* (/ orient pi) 180.0)       ""   )   )   (progn   (foreach n lst_pt(setq pt6 (polar n (+ orient (- (/ pi 2))) decalageCandelabre)      pt7 (polar n (+ orient 0) (/ decalageCandelabre 2))      pt8 (polar n (+ orient pi ) (/ decalageCandelabre 2)))(command "polylign" n pt6 "");; i have to get back entitie(command "polylign" n pt7 "");; i have to get back entitie(command "polylign" pt7 pt6 "");; i have to get back entitie(command "polylign" n pt8 "");; i have to get back entitie(command "polylign" pt8 pt6 "");; i have to get back entitie   )         (command "inserer"; this command it's for insert the lightings blocks but it doesn't work for the moment       "C:/pgn_mat/Blocs/candelabre3.dwg"       n       1       1       (* (/ orient pi) 180.0)       ""   )   ) ))
 
THANK YOU
 
I had prepare some pictures to show you but i don't arrive to insert it i'm sorry

mathieucraveiro 发表于 2022-7-6 06:59:42

there is another site in french where we can see the pictures of my program http://cadxp.com/topic/37941-probleme-gisement-abscisse-sur-une-droite/page__st__40
 
THANk you

mathieucraveiro 发表于 2022-7-6 07:01:21

i'm sorry but you cannot to se pictures in this website because we had to register :/

Lee Mac 发表于 2022-7-6 07:05:53

 
See the ssget reference I have attached to this post.
 
[ may require membership to view the attachment ]

mathieucraveiro 发表于 2022-7-6 07:08:10

Thank you Lee i understand now but it's strange because in the help documentation of lisp it's not write. So have you read my last post Lee. I'm blocked to get back my entities, i would like to get back it in the list variable with function (list x) ...
 
Thank you

mathieucraveiro 发表于 2022-7-6 07:11:16

Hello Every body
 
i have a problem to break my polylign
Actually i want to use this command and to break in two points my polylign
But the problem is i don't want that its the user chose two points and the entity polylign with (entsel) and (getpoint)
 
I know already my points (PT2 PT3) and my polylign name's "polyReseau"
 
So when i use the command "_break" :

(command "_break" ent "1" PT3 PT4)
 
 
The commanddoes not recognize PT2 and PT4.
 
Someone can help me ??
 
Thank you
页: 1 [2]
查看完整版本: Multiple-choice questions