Lee Mac Posted January 8, 2009 Share Posted January 8, 2009 Opps! How mach new listings. Ok Lee Mac. Coordinates, tables and so on is good training. I try I didn't think I could make it so that the info was in the drawing, but then I improved it and improved it till I could... Quote Link to comment Share on other sites More sharing options...
wannabe Posted January 9, 2009 Author Share Posted January 9, 2009 Lee, a great effort, that encompasses all of my requirements.......almost:) . The output value takes into consideration depths when working out the minimum distance for each block. But, the problem is, we need to ignore all the Z coords. One option would be for me to copy the drawing, flatten the lot and then run your command - which, if is the only option available, then still reduces the duration in comparison to the original method considerably. So I take my hat off now and thank you already. But, if you fancy the challenge, and want the pleasure of marrying all 5 of my sisters, then is there any chance you could somehow adjust to suit my ultimate requirements? Also, I showed the engineer the beta version and he then asked if we could somehow flag which side of the track the block is on. I've attached a copy of the drawing showing the difference between a 2d line and the corresponding distance output from the lisp. Cheers. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 9, 2009 Share Posted January 9, 2009 This should sort your Z coord issue: (defun c:pdis (/ oldlay cCurve cBlock txtpnt index ent dPt1 dPt2 blkDist blklist txt) (defun makelay (x) (if (not (tblsearch "Layer" x)) (progn (setvar "cmdecho" 0) (command "-layer" "m" x "") (setvar "cmdecho" 1) ) ;_ end progn (setvar "CLAYER" x) ) ;_ end if ) ;_ end defun (defun Make_Text (txt_pt txt_val) (entmake (list '(0 . "TEXT") '(8 . "TEXT") (cons 10 txt_pt) (cons 40 2.5) (cons 1 txt_val) '(50 . 0.0) '(7 . "STANDARD") '(71 . 0) '(72 . 0) '(73 . 0) ) ; end list ) ; end entmake ) ;_ end defun (vl-load-com) (setq oldlay (getvar "clayer")) (if (and (setq cCurve (entsel "\nSelect curve to measure > ")) (member (cdr (assoc 0 (entget (car cCurve)))) '("LINE" "POLYLINE" "LWPOLYLINE" "SPLINE" "ARC" "CIRCLE" "ELLIPSE") ) ;_ end member ) ; end and (progn (while (and (setq cBlock (ssget '((0 . "INSERT")))) (setq txtpnt (getpoint "\nSelect Point for Table > ")) ) ;_ end and (makelay "TEXT") (setq index (1- (sslength cBlock)) blklist "\n" txt 1 ) ;_ end setq (while (not (minusp index)) (setq ent (entget (ssname cBlock index)) dPt1 (cdr (assoc 10 ent)) dPt2 (vlax-curve-getClosestPointTo (car cCurve) dPt1) blkDist (expt (+ (expt (- (car dPt1) (car dPt2)) 2) (expt (- (cadr dPt1) (cadr dPt2)) 2) ) ;_ end + 0.5 ) ;_ end exp ) ;_ end setq (setq blklist (strcat (rtos (car dPt1) 2 1) "," (rtos (cadr dPt1) 2 1) " <---> " (rtos blkDist 2 1) ) ;_ end strcat ) ;_ end setq (Make_Text (polar txtpnt (* pi 1.5) (* 3.5 txt)) blklist) (setq index (1- index) txt (1+ txt) ) ;_ end setq ) ; end while ) ;_ end while ) ;_ end progn (princ "\n<!> Empty selection or this isn't a Curve (line, polyline, etc.) <!> ") ) ; end if (setvar "clayer" oldlay) (princ) ) ;_ end defun Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 9, 2009 Share Posted January 9, 2009 I notice that the text in your supplied drawing is a lot smaller than my code produces. I can changed the text element in my code to suit your specs if you wish? Quote Link to comment Share on other sites More sharing options...
wannabe Posted January 9, 2009 Author Share Posted January 9, 2009 I notice that the text in your supplied drawing is a lot smaller than my code produces. I can changed the text element in my code to suit your specs if you wish? No, no, have yourself some lunch and plan on making the most of my 5 sisters, mate. The table is sufficient for our purposes. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 9, 2009 Share Posted January 9, 2009 No, no, have yourself some lunch and plan on making the most of my 5 sisters, mate. The table is sufficient for our purposes. Haha, ok thanks Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 9, 2009 Share Posted January 9, 2009 But as for the flagging - I can work on this if you want - but could you post an example of what you are ultimately looking for? Quote Link to comment Share on other sites More sharing options...
wannabe Posted January 9, 2009 Author Share Posted January 9, 2009 All it needs to do additionally is add an L or R to say which side of the track it is on. Although if you can appreciate that some roads and rails are quite twisty(think of how rivers meander), it might be more of a challenge. Maybe if you take a metre either side of the tangent point on the road or track, create a straight line, then align the ucs with that, you can use the coordinates of the block and point on the road or track to determine which side the point is on. Maybe too complex for LISP? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 9, 2009 Share Posted January 9, 2009 The concept shouldn't be too hard, as you already have the perpendicular point - the hard part is know which is right and which is left when the track meanders - You can't just set a rule like (if the x coordinate of the base point is greater/less than the x coord of the perp. point... etc etc then put right/left I suppose you could look at the vector from perp point to base point and check out the direction, but then the left/right issue would still be there as you would have to look at previous points to know if it was right or left. I.e. in the picture below, the direction of the track would also have to be known. Quote Link to comment Share on other sites More sharing options...
wannabe Posted January 9, 2009 Author Share Posted January 9, 2009 Well there is an up and down line for every tracl, so dont worry about which is which. Just go from left to right for this purpose. The real concern would be a road that looks like a connection of joined up S's. Quote Link to comment Share on other sites More sharing options...
wannabe Posted January 9, 2009 Author Share Posted January 9, 2009 For example. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 9, 2009 Share Posted January 9, 2009 True, not an easy task. Quote Link to comment Share on other sites More sharing options...
wannabe Posted January 9, 2009 Author Share Posted January 9, 2009 All I can see working is taking a 1 metre piece of track for each block and creating a straight line to set the UCS about, then comparing coordinates relative to this. If I select a fence round the objects on the left, run the lisp and then do the right side there is no problem. Unless there is some way to make 2 regions in the drawing by closing the polylines. I expect this will be easier in higher level languages, though. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 9, 2009 Share Posted January 9, 2009 All I can see working is taking a 1 metre piece of track for each block and creating a straight line to set the UCS about, then comparing coordinates relative to this. If I select a fence round the objects on the left, run the lisp and then do the right side there is no problem. Unless there is some way to make 2 regions in the drawing by closing the polylines. I expect this will be easier in higher level languages, though. Nice idea, but as you say - easier in higher level languages. For now I expect you shall have to select your blocks wisely. Quote Link to comment Share on other sites More sharing options...
MaxwellEdison Posted January 9, 2009 Share Posted January 9, 2009 You could prompt the user to select left or right side blocks perhaps. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 10, 2009 Share Posted January 10, 2009 You could prompt the user to select left or right side blocks perhaps. Again a good idea, but you are still relying on the user selecting the correct blocks... Quote Link to comment Share on other sites More sharing options...
SEANT Posted January 10, 2009 Share Posted January 10, 2009 This is possibly a “non-issue” but interesting none the less. The closest point from an object to a 3D polyline may not give meaningful information if: But, the problem is, we need to ignore all the Z coords. The attached example is exaggerated to illustrate the point. 3dPolyIssue.dwg Quote Link to comment Share on other sites More sharing options...
David Bethel Posted January 10, 2009 Share Posted January 10, 2009 That is correct. One reason I approached it with 2D point values only. -David Quote Link to comment Share on other sites More sharing options...
ASMI Posted January 10, 2009 Share Posted January 10, 2009 > Lee Mac About right and left side. Create a temporary curve using _OFFSET on minimal distance and measure the distance from the block to the main and to the temporary curve. Do you understand what I hinted? Quote Link to comment Share on other sites More sharing options...
ASMI Posted January 10, 2009 Share Posted January 10, 2009 > SEANT, Lee Mac This is possibly a “non-issue” but interesting none the less. The closest point from an object to a 3D polyline may not give meaningful information if: There is vlax-curve-getClosestPointToProjection function, especially for such cases. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.