yajis_narif Posted June 7, 2011 Posted June 7, 2011 hiii !! is there any routine that extract only the parameter of a polyline in a zoom area ??? Quote
BlackBox Posted June 7, 2011 Posted June 7, 2011 I'm not sure I fully understand you question... Would the vla-getboundingbox and vla-zoom* functions work? Quote
yajis_narif Posted June 7, 2011 Author Posted June 7, 2011 for example i have a drawing with 4 polyline and 2 cercle and i applied the zoom into the area that contains 1 polyline so i want to extract the parameter of that polyline . thank you Quote
irneb Posted June 7, 2011 Posted June 7, 2011 Umm ... what "parameter"? I don't know of any parameter of polylines. If you mean you want to get the DXF data of the polyline / the ActiveX object, then look at the entsel, nentsel, nentselp, entget & vlax-ename->vla-object functions. To obtain all the entities currently visible is a bit complex, since it's not too easy figuring out where the current zoom is placed (more easy to figure out where the current virtual screen is - i.e. the portion which won't cause regens when viewed). Will have a bit of a check on this. Quote
irneb Posted June 7, 2011 Posted June 7, 2011 Try this. It gives 4 points (of the rectangle) in WCS for the extents of the current view. (defun GetCurrentView (/ vp vCtr vHeight vpHeight vpWidth vWidth) (vl-load-com) (setq vp (vla-get-ActiveViewport (vla-get-ActiveDocument (vlax-get-acad-object))) vCtr (trans (getvar "ViewCtr") 1 2) vHeight (getvar "ViewSize") vpHeight (vla-get-Height vp) vpWidth (vla-get-Width vp) vWidth (* vHeight (/ vpWidth vpHeight)) ) (list (trans (list (- (car vCtr) (/ vWidth 2.0)) (- (cadr vCtr) (/ vHeight 2.0)) (caddr vCtr)) 2 0) (trans (list (- (car vCtr) (/ vWidth 2.0)) (+ (cadr vCtr) (/ vHeight 2.0)) (caddr vCtr)) 2 0) (trans (list (+ (car vCtr) (/ vWidth 2.0)) (+ (cadr vCtr) (/ vHeight 2.0)) (caddr vCtr)) 2 0) (trans (list (+ (car vCtr) (/ vWidth 2.0)) (- (cadr vCtr) (/ vHeight 2.0)) (caddr vCtr)) 2 0) ) ) You can send it through to ssget with the CP option to select all entities inside / crossing the rectangle. Quote
irneb Posted June 7, 2011 Posted June 7, 2011 Sorry, the ssget only uses UCS not WCS. Here's the updated code: (defun GetCurrentView (/ vp vCtr vHeight vWidth) (vl-load-com) (setq vp (vla-get-ActiveViewport (vla-get-ActiveDocument (vlax-get-acad-object))) vCtr (trans (getvar "ViewCtr") 1 2) vHeight (getvar "ViewSize") vWidth (* vHeight (/ (vla-get-Width vp) (vla-get-Height vp))) ) (list (trans (list (- (car vCtr) (/ vWidth 2.0)) (- (cadr vCtr) (/ vHeight 2.0)) (caddr vCtr)) 2 1) (trans (list (- (car vCtr) (/ vWidth 2.0)) (+ (cadr vCtr) (/ vHeight 2.0)) (caddr vCtr)) 2 1) (trans (list (+ (car vCtr) (/ vWidth 2.0)) (+ (cadr vCtr) (/ vHeight 2.0)) (caddr vCtr)) 2 1) (trans (list (+ (car vCtr) (/ vWidth 2.0)) (- (cadr vCtr) (/ vHeight 2.0)) (caddr vCtr)) 2 1) ) ) To use it to select everything which is visible: (setq ss (ssget "CP" (GetCurrentView))) Or to select everything which is entirely visible (i.e. not just crossing over the view): (setq ss (ssget "WP" (GetCurrentView))) Quote
irneb Posted June 7, 2011 Posted June 7, 2011 If by the "parameter" of polylines you mean the parameter at which the curve intersects with the edges of the screen, you can then use the ssnamex function to obtain the positions of the intersections. From that you can use the vlax-curve-get-ClosestPointTo and then the vlax-curve-getParamAtPoint. Quote
yajis_narif Posted June 7, 2011 Author Posted June 7, 2011 i mean the DXf code of the polyline thank you irneb for your help i will try the program and reply ^^ Quote
yajis_narif Posted June 7, 2011 Author Posted June 7, 2011 irneb can this work on a bloc if for example i have a bloc that contains10 polylines if i zoom on 1 polyline can i get the DXF code of that one ?? Quote
irneb Posted June 7, 2011 Posted June 7, 2011 i mean the DXf code of the polyline thank you irneb for your help i will try the program and reply ^^That's quite easy:(if (setq ss (ssget "WP" (GetCurrentView) '((0 . "*POLYLINE")))) (progn (setq n (sslength ss)) (while (>= (setq n (1- n)) 0) (setq dxf (entget (ssname ss n))) ;; Do whatever you need with the DXF code of the current polyline ) ) ) It should select all the polylines visible and run your code for each one. irneb can this work on a bloc if for example i have a bloc that contains10 polylines if i zoom on 1 polyline can i get the DXF code of that one ??That's a bit more complex, since you have to convert the points to the block's internal definition. Then from there you need to work out if the polyline crosses or is contained by the rectangle - since ssget doesn't work inside blocks (unless you open the block in the BEdit command). I'm not sure if it would work with ssget's :N or :V modifier. I haven't used it before, but from the help it should select nested entities as well. Quote
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.