Jump to content

Recommended Posts

  • Replies 52
  • Created
  • Last Reply

Top Posters In This Topic

  • samifox

    26

  • pBe

    18

  • Lee Mac

    3

  • MSasu

    2

Top Posters In This Topic

Posted Images

Posted

this time ill ask you if i understand visually

pbe1.jpg

Posted

(setq st ( _pBe:from 1p 2.5 0)
             objrot (ssadd)
             tr 0)     
       (setq l1 (list (polar st (/ pi 2.0) 100) st
                             (setq 3p (polar st 0 (- h 5.0)))
                             (polar 3p (/ pi 2.0) 100)
                       )     

             l2 (list (polar st 0 100) st
                             (setq 3p (polar st (/ pi 2.0) (- v 5.0)))
                             (polar 3p 0 100)

 

the target function

 


(defun _pBe:from (p d m)
   (polar p (* pi (nth m '(0.25 
0.75 1.25 
1.75)))

(* d (sqrt 2))
   )
 )

rebar-Layout1-(2).jpg

  • 2 weeks later...
Posted

hi

 

i have a problem and i cant find the reaon

 

my code looking for 2 points that form a corner than i want to add 2 more points to form a squre,

 

i write down the coordinates of the final list and it seem ok but cant see the poins drawn by the -point command

 

any idea? (snap is off)

(setq UP (/ pi 2))
(setq DOWN (* pi (/ pi 2)))
(setq LEFT pi)
(setq RIGHT (* 3 (/ pi 2)))

(setq MAXDISTANCE 58);_maximum distance for root squre defenition
(setq SHOWPOINT 0)

(setvar 'pdmode 34)
(setvar 'cmdecho 0)


(defun C:MAIN (/ sspl pts columns walls)
 (if (setq sspl (ssget '((0 . "LWPOLYLINE")))) ;_ask the user to window select
   (if	(polyEntityCheck sspl)                  ;_if sset is valid
     (progn
(setq pts (mmd:extractVerts sspl))          ;_extract vertices
(setq columns (mmd:createColumn pts MAXDISTANCE))
;;;	(setq walls (createWall columns))
;;;	(setq rebar (createRebarwalls))
     )
   )
 )
)

  
;;;---------------------------------------------------------------------------------;
;;;     Function: polyEntityCheck(sset tol)                                         ;
;;;---------------------------------------------------------------------------------;
;;;  Description: check the members of the given selection set for                  ;
;;;               the following requirments:                                        ;
;;;               1.entity must be polyline                                         ;
;;;               2.must be closed polyline                                         ;
;;;               3.must be orthographic (within the boundry of the givn tolorance  ;
;;;  Pasadu :                                                                       ;
;;;               * if sset has a polyline defenition                               ;
;;;		    * if sset has closed defenition on                              ;
;;;                   *if sset poly geometry is ortographic (tolotance)             ;
;;;                     * return T                                                  ;
;;;                   * print : one or more polyline are not orthographic           ;
;;;                 * print : one or more polyline are not orthographic             ;
;;;               * print : one or more entites in the selection set                ;
;;;                         is not  polylines                                       ;
;;;---------------------------------------------------------------------------------;
;;; Argument :    sset - a selection set                                            ;
;;; Return   :    tol - the tolorance allowed for a line to be consider orthogaphic.;
;;;---------------------------------------------------------------------------------;
(defun polyEntityCheck(sset)
 T
 )
;;;--------------------------------------------------------------------;
;;;     Function: mmd:extractVerts                                     ;
;;;--------------------------------------------------------------------;
;;;  Description: This function will ask the user to select polylines  ;
;;;               and creates a list with all polylines's vertices     ;
;;;               selected  will be returned.                          ;
;;;--------------------------------------------------------------------;
;;; Argument :    a selection set consisting only polylines
;;; Return   :    a list consiste of the polyline's vertecis.
;;;--------------------------------------------------------------------;
(defun mmd:extractVerts	(sspl / i pts tpts)
 
   (progn
     (setq i 0)
     (while (< i (sslength sspl))
(setq pts (mapcar 'cdr
		  (vl-remove-if-not
		    '(lambda (e) (= (Car e) 10))
		    (entget (ssname sspl i))
		  )
	  )
)
(setq i (1+ i))
(setq tpts (cons pts tpts))
     )
   )

 (apply 'append tpts)
)

;;;--------------------------------------------------------------------;
;;;     Function: mmd:createColumn                                  ;
;;;--------------------------------------------------------------------;
;;;  Description:

;;;                 creates a column figure based on 2 parallel vertices.
;;;                 which respect the following condition
;;;  
;;;                 1. distance is less than MAXDISTANC
;;;                 2. distance is grater than 0
;;;                 3. angle is not orthgraphic
;;;
;;;                    the remaning 2 vertices composed by the x and y of the main 2 vertices
;;;------------------------------------------------------------------------------------
;;;                than te remaining2 parallel vertices is created based on the x and y coordinates.
;;;a defination list is to be created

;;;--------------------------------------------------------------------;
;;; Argument :    lst - list of vertices to be compared
;;;               maxlm - upper limit of the tolorance
;;;               minlm - button limit of the tolorance
;;; Return   :    a list of the column defination
;;;               0  - column id (linier numbrical)
;;;               10 - coordinates (4 vertices coordinate)
;;;               11 - center point
;;;		  40 - width
;;;               41 - hight
;;;               50 - angle (angle between the p1 and p3)
;;;--------------------------------------------------------------------;
(defun mmd:createColumn(lst dis / ma fe col)
   (setq fe 0 ma 0)
   (while (< ma (length lst))
(while (< fe (length lst))
	
		(if (and (< (fix(distance (nth ma lst) (nth fe lst))) dis);_
			 (> (fix(distance (nth ma lst) (nth fe lst))) 15);_if distance is between min and max
			(if (mmd:createColumn:isDiagonal (nth ma lst) (nth fe lst))
			  (progn
			        (princ "\nColumn found")
			  	(setq col (createSqure (nth ma lst) (nth fe lst)))
		 	  (command "_point" "_non" (nth 0 col) (nth 1 col) (nth 2 col) (nth 3 col)) 
			  (princ "\nAngle ignored")))
		  (princ "\nDistance ignored"))
	  (princ "\nEquality ignored"))
	 
  	(setq fe (1+ fe))
  );_while (<fe
  (setq ma (1+ ma))
     	(setq fe 0)
     );_while (ma
 );_defun

(defun mmd:createColumn:isDiagonal(p1 p3)
 (or
   (and (> (angle p1 p3) 0.2) (< (angle p1 p3) 1.4))
   (and (> (angle p1 p3) 1.7) (< (angle p1 p3) 3.0))
   (and (> (angle p1 p3) 3.3) (< (angle p1 p3) 4.5))
   (and (> (angle p1 p3) 4.9) (< (angle p1 p3) 6.1))
 )
)
(defun createSqure(p1 p3)
 (list p1 (list (car p3) (cadr p1))
p3 (list (car p1) (cadr p3)))
 )

(defun createWall(lst)
 (alert "Create Wall")
 )

 

thanks

shay

Posted

(setvar 'pdmode "yourpreferedmode");

 

EDIT: oh shoot. i didn't really looked at the code :lol:

 

Hang on. I'll have a look see....

Posted

hi pbe

but i can see only 2 point instead of 4

Posted

and what you think..am i good student? :D

Posted

and if i add

 

(command "line" (nth 0 col) (nth 1 col) (nth 2 col) (nth 3 col) "")

 

can see all lines

Posted

Ok what does this code do again? You may have to explain this routine once more shay

Posted
and if i add

 

(command "line" (nth 0 col) (nth 1 col) (nth 2 col) (nth 3 col) "")

 

can see all lines

How many points does your POINT command insert before it reaches the end, that is, finish and return to the command prompt? Could it be that your routine is actually crashing, because you are trying to insert more than one point at a time with the POINT command?
Posted
cant see the poins drawn by the -point command

 

any idea? (snap is off)

BTW, if OSNAPS are off, then using "non" is redundant.

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