Search the Community
Showing results for tags 'osnap'.
-
;| Author: Liviu Dovancescu Rel.: 1.0 Date: 25.11.2018 Translating a straight line at the tangent point of the line with the ellipse The point PE is not (yet) used. Limitations: The plane of ellipse parallel with the plane xOy (Z=constant) Tests: - AutoCAD 2005 SP 1: - none command active: OK - a command active and grips actives: OK - a command active and grips inactives: ERROR regarding selected objects - ZWCAD 2018 Version number 2018.03.16(29562)_x64: - none command active: OK - a command active: FAIL because of function SEL-ATPT |; (DEFUN MTEL (/ ;;Functions *ERROR* AFI-MESA COP-DETM INT-CEDR SEL-ATPT TAN-DREL TIP-ENTI ;;Variables A AA AF AG B BB C CC CMD D DD DL E EL F1 HLL I LN M OA OC OO PE PL SL SS T1 T2 XO YO ZO ) ;;Error function (DEFUN *ERROR* (s) (if HLL (vla-highlight LN :vlax-false)) (if SS (sssetfirst nil)) (if (not (wcmatch (strcase s) "*BREAK*,*CANCEL*,*EXIT*")) (prompt (strcat "\nError: " s)) ) (princ) ) ;;*ERROR* ;;Print the message x on " Command:" prompt (DEFUN AFI-MESA (x) (if HLL (vla-highlight LN :vlax-false)) (prompt (strcat "\n" x)) (princ) ) ;;AFI-MESA ;; Matrix Determinant (Upper Triangular Form) - Elpanov Evgeniy ;; Args: m - nxn matrix ;;Determinant m computation (DEFUN COP-DETM (m / d) (cond ( (null m) 1) ( (and (zerop (caar m)) (setq d (car (vl-member-if-not (function (lambda (y) (zerop (car y)))) (cdr m)))) ) (COP-DETM (cons (mapcar (function +) (car m) d) (cdr m))) ) ( (zerop (caar m)) 0) ( (* (caar m) (COP-DETM (mapcar (function (lambda (y / d) (setq d (/ (car y) (float (caar m)))) (mapcar (function (lambda (b c) (- b (* c d)))) (cdr y) (cdar m) ) ) ) (cdr m) ) ) ) ) ) ) ;;COP-DETM ;;Intersection between the circle (er, C (xc, yc, zc)) and the straight line ;;passing through (xf, yf) and having the slope em ;;Result: list ((x1 y2)(x2 y2)) (DEFUN INT-CEDR (xc yc zc er xf yf em / ae be de en) (setq en (- yf (* em xf)) ae (+ 1. (expt em 2.) ) be (+ (* -1. em en) (* em yc) xc) de (sqrt (+ (expt er 2.) (expt (* em er) 2.) (* -1. (expt en 2.)) (* -1. (expt yc 2.)) (* -1. (expt (* xc em) 2.)) (* 2. en yc) (* -2. en em xc) (* 2. em xc yc) ) ) ) (mapcar (function (lambda (x) (list x (+ (* em x) yf (* -1. em xf)) zc)) ) (list (/ (- be de) ae) (/ (+ be de) ae)) ) ) ;;INT-CEDR ;;On screen entity selection (entity type as per listTip) and prompting the text txt at "Command:" prompt ;;Example: (SEL-ATPT "\nSelect a line:" (list "AcDbLine")) ;;Result: list ((x y z) #<VLA-OBJECT ....>) if the entity type belongs to listTip, otherwise (nil nil). The point (x y z) belongs to the selected entity. (DEFUN SEL-ATPT (txt listTip / ObjSelected screenPoint ssetObj) (setq ssetObj (vla-add (vla-get-selectionsets (vla-get-activedocument (vlax-get-acad-object) ) ) (substr (rtos (getvar "CDATE") 2 9) 10) ) ) (prompt txt) (while (not ObjSelected) (if (setq screenPoint (if (vl-catch-all-error-p (vl-catch-all-apply (function (lambda () (while (/= 3 (car (setq screenPoint (grread nil 15 2)))) nil ) ) ) ) ) nil (cadr screenPoint) ) ) (vla-selectatpoint ssetObj (vlax-3d-point screenPoint)) ) (setq ObjSelected (if (= (vla-get-count ssetObj) 1) ;;Numai fata de un singur obiect se poate construi tangenta la elipsa (vla-item ssetObj 0) ) ) ) (vla-delete ssetObj) (list (if (and ObjSelected (vl-position (vla-get-objectname ObjSelected) listTip)) ;;Urmeaza si alte tipuri de entitati in ltip (vlax-curve-getclosestpointto ObjSelected (trans screenPoint 1 0)) ;;Punctul de selectie pe entitatea selectata in WCS (setq ObjSelected nil) ;;Anulare selectie ) ObjSelected ) ) ;;SEL-ATPT ;;Tangent point of the stright line passing through point ls and having the slope em with the ellipse (E)=f(x1 x2 x3 x4 x5) ;;Result: list (xT yT), where xT and yT are the coordinates of tangent point T ;;Example (TAN_DREL A B C D E (list XD YD ZD) M) (DEFUN TAN-DREL (x1 x2 x3 x4 x5 ls em / en xd xt yd) (setq xd (car ls) yd (cadr ls) en (- yd (* em xd)) xt (/ (+ (* x2 en) (* 2. x3 em en) x4 (* x5 em)) -2. (+ x1 (* x2 em) (* x3 (expt em 2.))) ) ) (list xt (+ (* em xt) yd (* -1. em xd)) (caddr ls)) ) ;;TAN-DREL ;;Check if the entity passing through point x, member of the selection set s, is a member af listTip ;;The colinearity condition of 3 points is checked. ;;Example: (TIP-ENTI (trans (getvar "LASTPOINT") 1 0) SS (list "AcDbLine")) ;;Result: #<VLA-OBJECT IAcadLine ....> or nil (DEFUN TIP-ENTI (x s listTip / ep li sp) (vlax-for SSobj s (if (vl-position (vla-get-objectname SSobj) listTip ) (progn (setq sp (vlax-safearray->list (vlax-variant-value (vlax-get-property SSobj "StartPoint"))) ep (vlax-safearray->list (vlax-variant-value (vlax-get-property SSobj "EndPoint" ))) ) (if (equal (COP-DETM ;;conditia de colinearitate sp, ep si x (if (and (equal (caddr x) 0. 1E-7) (equal (caddr sp) 0. 1E-7) (equal (caddr ep) 0. 1E-7)) (list (list (car sp) (cadr sp) 1) (list (car ep) (cadr ep) 1) (list (car x) (cadr x) 1) ) (list sp ep x) ) ) 0. 1E-7 ) (setq li SSobj) ) ) ) ) (vla-delete s) li ) ;;TIP-ENTI ;;Main (setq CMD (if (= (getvar "CMDACTIVE") 1) T)) ;;Flag comanda activa ;| (alert (strcat "1. CMDACTIVE: " (itoa (getvar "CMDACTIVE")) "\n2. CMDNAMES: " (getvar "CMDNAMES") "\n3. Grips inactives: " (itoa (vlax-get-property (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object))) "Count")) "\n4. Grips actives: " (itoa (vlax-get-property (vla-get-pickfirstselectionset (vla-get-activedocument (vlax-get-acad-object))) "Count")) ) ) |; ;;Line selection (if CMD ;;Test comanda activa (progn (if (= (vlax-get-property (setq SS (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object)))) "Count") 0) ;;Grips inactives (setq SS (vla-get-pickfirstselectionset (vla-get-activedocument (vlax-get-acad-object)))) ;;Grips actives ) (setq LN (TIP-ENTI (trans (getvar "LASTPOINT") 1 0) SS (list "AcDbLine"))) ;;Test obiect selectat=linie ) (mapcar (function set) (list (quote PE) (quote LN)) (SEL-ATPT "\nSelect line:" (list "AcDbLine")) ) ) ;;Ellipse selection (if LN (progn (if (not CMD) (progn (vla-highlight LN :vlax-true) ;;Linie aprinsa (setq HLL T) ;;Flag linie aprinsa ) ) (mapcar (function set) (list (quote PL) (quote EL)) (SEL-ATPT (if CMD "\n_tan to Ellipse:" "\nSelect Ellipse:") (list "AcDbEllipse")) ) (if EL (progn ;;Line and ellipse selected (setq ;;Ellipse OA (vlax-get-property EL "MajorRadius") ;;|OA| OC (vlax-get-property EL "MinorRadius") ;;|OC| OO (vlax-safearray->list (vlax-variant-value (vlax-get-property EL "Center"))) ;;Center O XO (car OO) YO (cadr OO) ZO (caddr OO) AF (vla-anglefromxaxis (vla-get-utility (vla-get-activedocument (vlax-get-acad-object))) (vlax-3d-point 0. 0. 0.) (vlax-get-property EL "MajorAxis") ;;Angle in radians between Ox and AB ) AA (polar OO AF OA) ;;Point A BB (polar OO (- AF pi) OA) ;;Point B CC (polar OO (- AF (* 0.5 pi)) OC) ;;Point C DD (polar OO (+ AF (* 0.5 pi)) OC) ;;Point D F1 (polar OO AF (sqrt (- (expt OA 2.)(expt OC 2.)))) ;;Foci F1 ;;Line SL (vlax-safearray->list (vlax-variant-value (vlax-get-property LN "StartPoint"))) ;;Start point line DL (vlax-safearray->list (vlax-variant-value (vlax-get-property LN "EndPoint" ))) ;;End point line AG (vlax-get-property LN "Angle") ) (if (and (equal;;Punctele A, C, SL si DL coplanare (COP-DETM (mapcar (function (lambda (x) (append x (quote (1)))) ) (list AA CC SL DL) ) ) 0. 1E-7 ) (= (caddr AA) (caddr BB) (caddr CC) (caddr DD));; (E) || (xOy) ) (progn (setq ;;Coefficients of the ellipse general equation in 2D A (+ (expt (* OA (sin AF)) 2.) (expt (* OC (cos AF)) 2.)) ;;A=OA^2*sin^2(af)+OC^2*cos^2(af) B (* 2. (- (expt OC 2.) (expt OA 2.)) (sin AF) (cos AF)) ;;B=2*(OC^2-OA^2)*sin(af)*cos(af) C (+ (expt (* OA (cos AF)) 2.) (expt (* OC (sin AF)) 2.)) ;;C=OA^2*cos^2(af)+OC^2*sin^2(af) D (* -1. (+ (* 2. A XO) (* B YO))) ;;D=-2*A*XO-B*YO E (* -1. (+ (* 2. C YO) (* B XO))) ;;E=-2*C*YO-B*YO ) (cond ((equal (sin AG) 0. 1E-7) ;;(D) || Ox (mapcar (function set) (list (quote T1) (quote T2)) (mapcar (function (lambda (y) (list (/ (+ (* B y) D) -2. A) y ZO)) ) (list (+ YO (sqrt (- (expt OA 2.) (expt (- (car F1) XO) 2.)))) (- YO (sqrt (- (expt OA 2.) (expt (- (car F1) XO) 2.)))) ) ) ) ) ((equal (cos AG) 0. 1E-7) ;;(D) || Oy (mapcar (function set) (list (quote T1) (quote T2)) (mapcar (function (lambda (x) (list x (/ (+ (* B x) E) -2. C) ZO)) ) (list (+ XO (sqrt (- (expt OA 2.) (expt (- (cadr F1) YO) 2.)))) (- XO (sqrt (- (expt OA 2.) (expt (- (cadr F1) YO) 2.)))) ) ) ) ) ((not (inters SL DL AA BB nil)) (setq T1 CC T2 DD)) ;;(D) || AB ((not (inters SL DL CC DD nil)) (setq T1 AA T2 BB)) ;;(D) || CD (T ;;Linia nu e paralela cu axele elipsei si nici cu axele de coordonate Ox sau Oy (setq M (/ (sin AG) (cos AG)) I (INT-CEDR XO YO ZO OA (car F1) (cadr F1) (/ -1. M)) T1 (TAN-DREL A B C D E (car I) M) T2 (TAN-DREL A B C D E (cadr I) M) ) ) ) ;;User interface (if CMD (progn (setq PL (trans PL 0 1) ;;In UCS T1 (trans T1 0 1) ;;In UCS T2 (trans T2 0 1) ;;In UCS ) (osnap (if (< (distance T1 PL) (distance T2 PL)) T1 T2) "_non" ) ) (progn (setq SS (ssadd)) (mapcar ;;Lista->Set de selectie (function (lambda (x) (setq SS (ssadd x SS)))) (mapcar ;;Desenare puncte (function (lambda (x) (entmakex (append (mapcar (function cons) (list 0 100 67 8 100) (list "POINT" "AcDbEntity" (if (= (getvar "TILEMODE") 1) 0 1) "Defpoints" "AcDbPoint") ) x ) ) ) ) (list (list (cons 10 T1)) (list (cons 10 T2))) ) ) (sssetfirst nil SS) ;;Aprinde grip-uri (setq SS nil) (vla-highlight LN :vlax-false) ;;Stinge linie (princ) ) ) ) (AFI-MESA "The Line and the Ellipse are not coplanar or the plan of Ellipse is not parallel to the plane xOy.") ) ) (AFI-MESA "Selected entity is not an Ellipse.") ) ) (AFI-MESA "Only Line allowed.") ) ) Under AutoCAD, the OSNAP mode _tan works OK in case of the circle. Not in case of the ellipse. I am talking about the translation of the selected object at the tangent point with an ellipse. The above code tries to solve this problem. The geometric solution is the one in the attached drawing. If no command active, the program draws the tangent points of a selected straight line with the ellipse. If a command is active (OSNAP mode) and the program is invoked, it works well only if grips are active (fired). Otherwise (inactive grips), the selected items in the active command are lost, in the selection set remaining the ellipse. A tricky solution would be by saving the selection set from the active command, the command name, and restoring the context after the ellipse was selected. Please test the program and give me a hand. Thank you in advance. Ellipse.dwg
-
Hello guys I am typing this because i am out of ideas The problem we are having at the office is that when we try to use the geometric center with closed simple polygons, the geometric center is not quite in the center. Even with really simple polygons. I found online that the problem could be some imported elements from other programs (like archicad or arcgis or something like that) , and that if you move your elements near the 0,0,0 coordinate point, the problem is solved. BUT, as you guessed, we can not do that since we work with real coordinates and we need them exactly referenced (the coordinates). The weird thing is that, the "infected" files we have (the ones where the geometric center does not work) infect new files even if we copy a line or a polygon or anything at all. Another thing is that it only happens in autocad architecture (2017), we have autocad civil 2016 and the problem does not happen there I am attaching some files with the problem EXAMPLE-GEOMETRIC CENTER.dwg
-
Hey everyone, I am new to drafting and been having trouble with Osnaps and Ortho clashing when i draw lines, plines, measure and etc. Pretty much anytime i type in a command, and sometimes randomly. What i mean is that whenever i press F3 which is key bound to snaps or F8 which is key bound to Ortho they scramble up. Example: Im drawing a line to the edge of another line so to keep it straight i press ortho but it turns osnaps off, so i press osnaps to turn it back on, but it than turns my ortho off. So i press osnaps again and it actually turn it back, so than i go back to pressing ortho and it turns my osnaps off again and its a big merry-go-round that takes up to 5 minutes to get correct. Sometimes i just end up closing AutoCAD completely to fix this, but after awhile it starts back up again. If anyone knows how to fix this, it would be much appreciated! Thanks.
-
I've had this issue before but never really investigated it further until today. I use a lot of polygonal viewports to show twisting routes of water mains along a section of an OS map and add connection details in the remaining paper space areas. What I've noticed when using this method is that OSNAPS still snap to the map features in the empty space, however, only within a rectangular area that would fit the extents of the polygonal viewport. I'm not looking for a fix as it's not a major issue, but just thought I'd report it and see if anyone else has noticed it and knows why it happens?
- 4 replies
-
- polygonal viewport
- polygonal
-
(and 2 more)
Tagged with:
-
is there any way to get the osnap to stop finding ends of a wipeout? I have a tag that I use with labels to show a material. because of the tight quarters of sections at times I added a wipeout behind the attribute. the frame around the 'tag' has semi-circles at the ends and it is a polyline. as you know wipeouts don't work with curved polylines so I had to create a new polyline behind the curved polyline with a ton of endpoints so it followed the curve as best as possible. now when I insert the 'tag' and add a leader it snaps to every point that I created with the wipeout polyline. the frame for the wipeout if off and it is still grabbing any point that it finds (except what I am looking for). so is there anything I can do?
-
Hi! I'm trying out the dline command in Autocad LT 2016, and it works pretty well. However, after each command is finished, and I start a new dline command - the object snap resets and no snap setting is selected, so I have to select them everytime I start a new dline command. You guys have any idea why it doesn't save the OSNAP state? Works fine with line command. Edit: The object snap modes gets deselected, but the OSNAP is still set to "ON". If I during the dline command type S(NAP), it shows as "ON".
-
Osnap is very sensitive, how to adjust? Autocad 2014
Sengna posted a topic in AutoCAD 2D Drafting, Object Properties & Interface
It happened for the past couple of day, i had the endpoints osnap on and i tried to snap a line at top left corner but the cursor was jumping around, what's a pain! i went in OPTIONS and drafting and adjusted the Aperture size but didn't work, does anyone know how to fix this? thanks -
osnap only snapping to "top" of object
toonamo posted a topic in AutoCAD 2D Drafting, Object Properties & Interface
in earlier versions of autocad osnap used to snap to all endpoints if i had it enabled. Now osnap only snaps to endpoints that would be visiable if the object was solid. If a endpoint is "through", underneath, or inside a object. I am unable to snap to it. I am using autocad 2015 does anyone know where the setting is to toggle this behavior?- 3 replies
-
- osnap
- autocad2015
-
(and 1 more)
Tagged with:
-
Problem with OSNAP to tangent
Valiance posted a topic in AutoCAD 2D Drafting, Object Properties & Interface
Hi, I'm having a problem with OSNAP and am not sure what I'm doing wrong. As you can see from the attached photo, I am using offset to create a parallel line to the one selected (the leftmost line) that I am trying to place tangent to the circle in the center. However, the tangent snap points (which should be visible in the picture) aren't working properly and cause the line to snap to a position inside the circle rather than tangent to it. My command process is offset -> through -> select line -> select TAN onsnap option -> hover over circle near desired tangent point. Any help would be appreciated. Thanks! -
Snapping to vertices on spline
kizaerf posted a topic in AutoCAD 2D Drafting, Object Properties & Interface
I made a spline and there are clear verticies, but autocad just refuses to snap to them. All my osnaps are on and it will snap to some points on the spline but not one where there is a clear vertex. i am stumped. -
I don't know what I changed, but suddenly when copying or moving sections already drawn, with Ortho on, when I release from my move, the entire selection has shifted. This is quite frustrating, and never happened before. I take these to a point on a line that seems to highlight or 'accept' that location ~ when I click and enter, it's on the same axis, but NOT where I intended. Unfortunately, I do not know what the 'problem free' settings were, but I currently have the following activated in OSNAP: Endpoint Midpoint Node Intersection Nearest Any assistance would be appreciated, thanks.
-
Need assistance figuring OSNAP for my LISP! THANKS!
tmelancon posted a topic in AutoLISP, Visual LISP & DCL
Hello all. I have a LISP routine that I have been using forever now so excuse me if it is written sorta outdated to what it could look like if it were updated. It is a balloon(bubble) routine to insert letters or numbers inside a sized bubble with a line and an arrow. The problem I am having is that when running the command after selecting my first point i have to physically turn off OSNAP then after I enter the numbers and finish the command turn OSNAP back on because if I do not it distorts the arrow... I have a mouse with extra programmed buttons that allows me to speed up the process as if it never happens, but still thats not the point. It would be nice to just keep all my snaps on all the time and let the code and just continue to breeze through my drawings. I have tried a few things and I am finished with trying for now. Besides I have others in my cad department that have regular mice and we all believe it could be made better. Figured I would take it to the CAD community, because after all I know this is what some of you live for also. So to sum it up I am basically looking for the code to be revised so that when I start the command it will change OSMODE properly to allow for everything to be entered with no problems. Whether SNAP is turned off/on of OSMODE is altered I do not really care just as long as SNAP IS ON DURING FIRST USER POINT so that my leader is on my pipe and SNAP IS BACK TO ALL ON after the command. THANKS THANKS THANKS IN ADVANCE! Sorry if I am missing it guys, I have tried. Here is the code: ************************ DATAPOINT BUBBLE INSERTION ************************** (defun c:BALLOON (/ oldlayr oldos) (setq oldlayr (getvar "clayer")) (command "._-layer" "s" TEXT "") (initget (+ 1)) (setq pt1 (getpoint "\nDatapoint location on pipe: ")) ; Get 1st loc (initget (+ 1 32)) (command "OSNAP" "NONE") (setq pt2 (getpoint pt1 "\nDatapoint bubble location: ")) ; Get 2nd loc (initget (+ 1 2 4)) (if (= etype "G") (progn (setq dps (strcase (getstring "\nEnter datapoint ID (A1 - A999) or (A1 - AZ99): "))) ; Get DP# (if (< (strlen dps) 3) (setq csize (* (getvar "userr1") 1.2)) ; balloon for A1 (progn (if (< (strlen dps) 4) (setq csize (* (getvar "userr1") 1.9)) ; balloon for A22 (setq csize (* (getvar "userr1") 2.3)) ; balloon for A333 ) ) ) ) (progn (setq dpnum (getreal "\nEnter datapoint number (1.0-999.9): ")) ; Get DP# (setq dps (rtos dpnum 2 1)) (if (< (strlen dps) 4) (setq csize (* (getvar "userr1") 1.6)) ; balloon for 9.9 (progn (if (< (strlen dps) 5) (setq csize (* (getvar "userr1") 2.0)) ; balloon for 99.9 (setq csize (* (getvar "userr1") 2.4)) ; balloon for 999.9 ) ) ) ) ) (command "._circle" pt2 csize) (setq a (angle pt2 pt1)) (setq OLDOS (getvar "OSMODE")) (setvar "OSMODE" 0) (command "._line" pt1 (osnap (polar pt2 a csize) "nearest") "" ) (setvar "OSMODE" OLDOS) (command "._solid" pt1 (polar pt1 (- a 85) (getvar "userr1")) (polar pt1 (+ a 85) (getvar "userr1")) "" "") (command "._text" "m" pt2 (GETVAR "USERR1") 0 dps) (command "._-layer" "s" oldlayr "") (prin1)) -
Help With LT05 Macro Autonumber and OS Near
Chumbawamba posted a topic in The CUI, Hatches, Linetypes, Scripts & Macros
I have this macro (from Somewhere) to increment numbers on each click. I would like it to set to object snap Near before i click so it will just snap the number to the nearest thing i click. *^C^C_text;\;$M=$(+,$(getvar,USERI1),1);setvar;USERI1;$M=$(+,$(getvar,USERI1),1); Also is there anyway to change this so the text is rotated 90deg? As a separate macro. Any help greatly appreciated. Thanks in Advance. -
Inaccurate Nearest Osnap
aglaerum posted a topic in AutoCAD 2D Drafting, Object Properties & Interface
Hi My "Nearest" osnap is not even close to snapping to my circle. All other snaps are working fine, nearest snap are working on lines and rectangles, not at all on circles. Whats going on? Image attached.- 85 replies
-
- nearest
- innacurate
-
(and 1 more)
Tagged with:
-
Lines snap at an offset distance (0.0000274 m e.g.) from the actual point. What change of settings can resolve it?
-
Hello Let's say I want to move a text. I pick it up and place it somewhere. I don't want it to be snapped anywhere so I am careful that yellow OSNAP mark is not showed anywhere. I pick the destination point and text disappears! What happened?! Of course... cursor was too close to some line and it was snapped to it's start point But the start point was outside my view, so I could not see the yellow marker. I never want to snap to a point that is outside my view! So: Is it possible to tell autocad, that it uses OSNAP only for points that are inside the current view?
-
Autocad 2010 won't grab endpoint of polyline splined with pedit
incarnate posted a topic in AutoCAD 2D Drafting, Object Properties & Interface
I was using acad 2007 and it did exactly what I want. I am now using acad 2010 and for some reason when I draw a polyline and spline it with pedit, I cannot grab the endpoint of the line. The osnap doesn't see it. If I hit tab a bunch of times eventually I can get it to grab, but that is not efficient. It works fine with normal splines, but I use autocad as an illustration tool and regular spline doesn't work for my needs. Any ideas or help on a setting or something that I might be able to change would be greatly appreciated. This is a make or break deal for me with autocad. I will have to go back to 2007 if I can't correct this because a large amount of what I do is in these types of splines. Thank You.