In ModelSpace I have an area limited by some curves (joined them to have AcDbRegion).
I have also drawn AcDbLine.
What I need is to split line to get lines only inside area.
The next is the distance from the start of the line element to the first break (or cut) in the line element. The successive group code 41 values continue to list the start and stop points of the line element in this segment of the mline.
I know how to get intersection points, but how can I find if line conecting two intersection points is inside? or outside area?
CAD DeveloperCAD Developer69611 gold badge1111 silver badges1818 bronze badges
3 Answers
If you want to do it manually (with an algorithm that will work with any APIs), I would suggest you use the 'winding number algorithm' for the purpose of Point In Polygon calculation. It does not take in consideration bulges in the polygon, but it is very fast is implemented properly allowing me to beat AutoCAD's API by a fold of 2x.
Another possibility, is to draw a temporary line from the point you are testing to infinity, and test how many intersection it has with your polyline. If the number of intersections is odd, then you are inside the polyline; if it is even, then you are outside of the polyline. If the intersection testing is done with the API of the application, it should take in consideration the bluges in the polyline vertices.
JFTxJJFTxJ
Augusto GoncalvesAugusto Goncalves6,97422 gold badges1010 silver badges3232 bronze badges
- Get the polyline that defines the outside of your region.
- Select by polygon using the region polyline vertices. Or select by crossing polygon using the polyline vertices if you want everything inside or crossing the region.
66911 gold badge88 silver badges1111 bronze badges
Not the answer you're looking for? Browse other questions tagged autocad-pluginobjectarx or ask your own question.
Similar Messages:
AutoCAD Visual LISP / AutoLISP :: Wblock To Erase Or Not To Erase?
Feb 18, 2013Wblock when run from the command line used to erase the entities selected, now it seems it does not, but the dialog box shows an option to keep or erase the selected entities.
Any variable name that controls this functionality?
Any variable name that controls this functionality?
AutoCAD Visual LISP / AutoLISP :: Reduce Polyline With Multiple Vertices To Single Polyline
Jun 7, 2012I would like to take all the vertices out of a multiple-vertices polyline so that it reduces to just its start and end points, can this be done?
AutoCAD Visual LISP / AutoLISP :: 3D Polyline To Polyline To Spline With Max
Sep 21, 2013Due to modeling purposes, I need to convert a 3D polyline to a spline. What I have been doing is:
- change polyline fit/smooth to cubic from properties
- convert polyline to spline by typing spline -> object
- method -> fit from properties
You can see the original 3D polyline (green) and the resulting spline (magenta) in the attached drawing.When I zoom in and measure the distance between the two entities at different points along them, at some points the perpendicular distance exceeds 5 millimeters, and I want to ensure the deviation remains under 1 millimeter or even less.
I know I can change the knot parameterization of the spline, and this does work at some locations, but the difference increases at others.Why is there a 5.6 mm difference between the spline fit point and 3D polyline vertex, as measure in the attached drawing?
Now, I can go and manually stretch the fit point to coincide with the vertex. Also, I can add fit points between existing ones to drag the spline closer to the original 3D poly.
However, some of my polys are really long, and it is very time-consuming to do this manually while measuring points along the entities to make sure the distance stays small enough.
how to automate this process? For example a lisp that would maybe take the original vertex points, add say maybe 3 (not too many) new ones between them, and then generate a spline while making sure the deviation is less than the set value of 1mm? I am using AutoCAD 2013.
- change polyline fit/smooth to cubic from properties
- convert polyline to spline by typing spline -> object
- method -> fit from properties
You can see the original 3D polyline (green) and the resulting spline (magenta) in the attached drawing.When I zoom in and measure the distance between the two entities at different points along them, at some points the perpendicular distance exceeds 5 millimeters, and I want to ensure the deviation remains under 1 millimeter or even less.
I know I can change the knot parameterization of the spline, and this does work at some locations, but the difference increases at others.Why is there a 5.6 mm difference between the spline fit point and 3D polyline vertex, as measure in the attached drawing?
Now, I can go and manually stretch the fit point to coincide with the vertex. Also, I can add fit points between existing ones to drag the spline closer to the original 3D poly.
However, some of my polys are really long, and it is very time-consuming to do this manually while measuring points along the entities to make sure the distance stays small enough.
how to automate this process? For example a lisp that would maybe take the original vertex points, add say maybe 3 (not too many) new ones between them, and then generate a spline while making sure the deviation is less than the set value of 1mm? I am using AutoCAD 2013.
AutoCAD Visual LISP / AutoLISP :: Erase Original Line Drawn
May 15, 2013I have pieced this lisp together from a few I have come across here in the groups, but am now stuck with the final pieces. Once the pline is drawn I would like the lisp routine to select the pline (last ?) instead of the user doing so. I would then like to offset the line 1 (foot) and then erase the original line drawn, so the user does not have to.
AutoCAD Visual LISP / AutoLISP :: Erase All Points In Specific Layer
Apr 9, 2013I have a lisp which I use to erase all points in a specific layer.
(defun cPL ()
(setq ss1 (ssget 'x' (list '(0 . 'point')'(8 . 'Points'))))
(command '.erase' ss1 ')
(princ)
)
It is working only if I have the points in the DWG. If there are no points, I receive 'Unknow command DPL'. Is there anything I can do in order to avoid this error?
(defun cPL ()
(setq ss1 (ssget 'x' (list '(0 . 'point')'(8 . 'Points'))))
(command '.erase' ss1 ')
(princ)
)
It is working only if I have the points in the DWG. If there are no points, I receive 'Unknow command DPL'. Is there anything I can do in order to avoid this error?
AutoCAD Visual LISP / AutoLISP :: Trim Then Join Polylines
Jul 15, 2013I've been looking to download a lisp that can trim (TR) and the (PE, join) polylines. two at a time or multiple... I've tried writing the lisp routine but I cannot do it correctly.. Any good lisp routine? Also, if there's one to trim & fillet w/a radius.. Hopefully there's two different routines but if there's one then even better...
AutoCAD Visual LISP / AutoLISP :: Trim Selected Text(s) With A Divisor?
Feb 2, 2013I need a program to trim selected text(s) with a divisor.
suppose that the divisor character is: '/'
(selected text>result
textL/textR > textR
xxx/yyy >yyy
t12x/5678 >5678
I should use some commands like:
;;;;div='/':
(setq str 'xxx/yyy')
(setq pos (vl-string-position (ascii '/') str))
(setq len (strlen str))
(setq RGT (substr str (+ pos 2) (-(- len pos)1))) ;;=text after '/'
but I need a LISP program that:
1-ask user to give a divisor char: (Divisor character: </>)
2-ask user to select text(s) but program should filter selected text(s) with divisor (*/* pattern)
(if (null #div#)(setq #div# '/'))
(if (and
(setq #div# if (= (setq tmp (getstring (strcat '
Divisor character: <' #div# '> ') ) ) ' ) #div# tmp ) )
(setq ss (ssget '_:L' (list '(0 . '*TEXT') (cons 1 (strcat '*' #div# '*')))))
)
suppose that the divisor character is: '/'
(selected text>result
textL/textR > textR
xxx/yyy >yyy
t12x/5678 >5678
I should use some commands like:
;;;;div='/':
(setq str 'xxx/yyy')
(setq pos (vl-string-position (ascii '/') str))
(setq len (strlen str))
(setq RGT (substr str (+ pos 2) (-(- len pos)1))) ;;=text after '/'
but I need a LISP program that:
1-ask user to give a divisor char: (Divisor character: </>)
2-ask user to select text(s) but program should filter selected text(s) with divisor (*/* pattern)
(if (null #div#)(setq #div# '/'))
(if (and
(setq #div# if (= (setq tmp (getstring (strcat '
Divisor character: <' #div# '> ') ) ) ' ) #div# tmp ) )
(setq ss (ssget '_:L' (list '(0 . '*TEXT') (cons 1 (strcat '*' #div# '*')))))
)
AutoCAD Visual LISP / AutoLISP :: Delete Offset Line
Sep 6, 2013There are many lisp that draw offset line but what about opposite way , I have wall of double line i need to delete one of them let's say inside wall line .
why i need to do this usually when i tracing in external program like autocad architecture or Revit or archicad i just need outline of exterior and interior walls !.
is there way that can delete the offset line ?(or within range predefined in lisp to prevent interfering of lines deletion).
why i need to do this usually when i tracing in external program like autocad architecture or Revit or archicad i just need outline of exterior and interior walls !.
is there way that can delete the offset line ?(or within range predefined in lisp to prevent interfering of lines deletion).
AutoCAD Visual LISP / AutoLISP :: Line Trim - Draw Lots Of Plumbing Plans
Jan 9, 2013This is to trim a line that crosses another. I draw lots of plumbing plans. It draws a circle based on 'dimscale', trims a line to that circle, then erases the circle. The problem is if you miss the trim point (PT2) it does not erase the circle and you lose your object snaps.
;Pipeline Break
(Defun C:bb (/ s1 ds1 r1 PT1 PT2 AX)
(setq s1 (getvar 'osmode'))
(setq ds1 (getvar 'dimscale'))
(setvar 'osmode' 63)
(setq r1 (* ds1 0.03125))
(setq PT1 (getpoint '
[code]....
;Pipeline Break
(Defun C:bb (/ s1 ds1 r1 PT1 PT2 AX)
(setq s1 (getvar 'osmode'))
(setq ds1 (getvar 'dimscale'))
(setvar 'osmode' 63)
(setq r1 (* ds1 0.03125))
(setq PT1 (getpoint '
[code]....
AutoCAD Visual LISP / AutoLISP :: Find Offset Origin Of Layout
May 8, 2013I want to know the correct way to find the offset origin of a layout in an AutoCAD drawing. Let say I have a drawing that has many items on it. And I create a layout showing just the items in the lower right corner of the drawing. I want to know the offset origin of this layout relative to the Model space.
I came across some LISP commands that are supposed to do just that:
(vl-load-com)(setq activelayout (vlax-get (vla-Get-ActiveDocument (vlax-Get-Acad-Object)) 'ActiveLayout ))(setq activeplotorig (vlax-get activelayout 'PlotOrigin))
Unfortunately, the commands don't seem to work because it always returns (0.0 0.0). That cannot be right.
I came across some LISP commands that are supposed to do just that:
(vl-load-com)(setq activelayout (vlax-get (vla-Get-ActiveDocument (vlax-Get-Acad-Object)) 'ActiveLayout ))(setq activeplotorig (vlax-get activelayout 'PlotOrigin))
Unfortunately, the commands don't seem to work because it always returns (0.0 0.0). That cannot be right.
AutoCAD Visual LISP / AutoLISP :: Auto Offset For Selected Items
Jan 25, 2013I wish to have a lisp than enable to do automatic offset base on some selection of lines ,circles or polylines object as shown in attachment.
AutoCAD Visual LISP / AutoLISP :: Create A Line With Text Offset
May 6, 2013I am a beginner at LISP and this is a bit out of my league... and I'm trying to create a lisp where I can draw a polyline between 2 points that also places text with the actual distance offset above the line.
I did find this post and I'm not quite catching on.. [URL] ......
I did find this post and I'm not quite catching on.. [URL] ......
AutoCAD Visual LISP / AutoLISP :: Calculate Points Offset To Pline
Sep 27, 2013what I am attempting -
Pick a line
Pick a starting point on the line
Pick a ending point on the line
Pick side to offset
create list of offset points
Create a new line with a offset
I think I could do this using brute force, but would prefer a mathematical solution.
Pick a line
Pick a starting point on the line
Pick a ending point on the line
Pick side to offset
create list of offset points
Create a new line with a offset
I think I could do this using brute force, but would prefer a mathematical solution.
AutoCAD Visual LISP / AutoLISP :: Selecting Object And Passing To VLA Offset
Feb 29, 2012I'm trying to complete the code to select a p-line on layer G-POLY-GSF w/o asking for input. this (setq ent (ssget 'X' (list (cons 8 'G-POLY-GSF'))) dosen't seem to work. What I'm I missing here?
(defun cf8 (/ ent dist obj)
(vl-load-com)
(setq ent (car (entsel '
Select line to offset: '))
;(setq ent (ssget 'X' (list (cons 8 'G-POLY-GSF')))
[Code]....
(defun cf8 (/ ent dist obj)
(vl-load-com)
(setq ent (car (entsel '
Select line to offset: '))
;(setq ent (ssget 'X' (list (cons 8 'G-POLY-GSF')))
[Code]....
AutoCAD Visual LISP / AutoLISP :: Get Enames Of Each Polyline
Apr 26, 2013this is a Offset cutting plane line I want it to be all polylines but I can't get the ename of the end points of the polylines dose anyony know how
(defun ccp (/ pt2)
(SETVAR 'CMDECHO' 0)
(setvar 'angbase' 0)
(setvar 'angdir' 0)
(command 'polarang' 1)
(setq pt1 (getpoint '
[Code]....
(defun ccp (/ pt2)
(SETVAR 'CMDECHO' 0)
(setvar 'angbase' 0)
(setvar 'angdir' 0)
(command 'polarang' 1)
(setq pt1 (getpoint '
[Code]....
AutoCAD Visual LISP / AutoLISP :: Sum Of Polyline Lengths
May 21, 2012Is it possible to determine the sum of the lengths of all of the polylines on a certain layer? I'm trying to determine the total length of joint sealant on a building's exterior.
AutoCAD Visual LISP / AutoLISP :: Change Z Value Only On 3D Polyline
Aug 23, 2012I am using acad 2010. I have a contour generator that uses 3d polylines to make contours. I get depressions or tops where I don't want them. I need a lisp routine that will allow me to adjust the z value only on any 3d polyline. I need to raise or lower the z value at any vertex and repeat if necessary. I don't need to prompt the user- I am the user.
AutoCAD Visual LISP / AutoLISP :: Set Polyline Elevation
Jul 19, 2013I create contour line in TOPOGRAPH program, and I import these polylines to AUTOCAD. I have to set elevation for each polyline manually, and I waste a lot of time doing that.
So looking for lisp doing that automatically. I mean, invoke the command, set the first elevation and them select the polylines.
e.g. The first elevation is 530. The next polyline that I select is 531 and so on.
So looking for lisp doing that automatically. I mean, invoke the command, set the first elevation and them select the polylines.
e.g. The first elevation is 530. The next polyline that I select is 531 and so on.
AutoCAD Visual LISP / AutoLISP :: Region To Polyline
Feb 17, 2009
For the sake of editing, I sometimes make LWPOLYLINES and convert them to regions so that I can union and subtract and intersect, etc.
then sometimes, like now, I want to work with them like as LWPOLYLINES again.
is there some command I don't know, or some routine or shall I make one?
then sometimes, like now, I want to work with them like as LWPOLYLINES again.
is there some command I don't know, or some routine or shall I make one?
AutoCAD Visual LISP / AutoLISP :: Up-to-date Offset Command - Line Prompts
Jun 7, 2012I posted a version of the Offset command that lets you Undo individual Offsets and change the offset distance/Through option, without getting out of the command, at Cadalyst CAD Tips: URL....
It's an upgraded version of an earlier concept by Gopal Ramesh. It's been downloaded almost three times every day since it went up, so I guess people expect it will be useful.
But the website's description includes: 'this routine does not provide access to the Layer or Erase options of the built-in Offset command.' The reason for that is that I'm working back in 2004, so those options are not present for me to emulate. [The Undo option in the routine is one that was added in some later version, but is a very useful enhancement for people using older versions, like me.]
I do also have an Offset-to-any-Layer [not just the source's or the current Layer] routine posted there: URL....
And I have a simple little routine to Offset something and Erase the source object. So I think I have all the 'pieces' to include those options that newer versions have, but that I don't. I would like to combine the functionalities into the Offset-with-running-options routine. That way, if people want to use it to redefine the Offset command as I have done, in order to get the while-running distance change option, those working in newer versions won't be losing the Erase and Layer options in the process, and those in older versions will be gaining yet more options.
It's an upgraded version of an earlier concept by Gopal Ramesh. It's been downloaded almost three times every day since it went up, so I guess people expect it will be useful.
But the website's description includes: 'this routine does not provide access to the Layer or Erase options of the built-in Offset command.' The reason for that is that I'm working back in 2004, so those options are not present for me to emulate. [The Undo option in the routine is one that was added in some later version, but is a very useful enhancement for people using older versions, like me.]
I do also have an Offset-to-any-Layer [not just the source's or the current Layer] routine posted there: URL....
And I have a simple little routine to Offset something and Erase the source object. So I think I have all the 'pieces' to include those options that newer versions have, but that I don't. I would like to combine the functionalities into the Offset-with-running-options routine. That way, if people want to use it to redefine the Offset command as I have done, in order to get the while-running distance change option, those working in newer versions won't be losing the Erase and Layer options in the process, and those in older versions will be gaining yet more options.
AutoCAD Visual LISP / AutoLISP :: Draw Polyline With Clipping Outside
Mar 7, 2012is there a way to draw a polyline and have autocad clip everything outside of that polyline and discard it so that i end up with a smaller drawing. only the information in that polyline, nothing outside of the polyline
AutoCAD Visual LISP / AutoLISP :: Polyline Width And Fillet
Feb 5, 2013I've been searching on and off all morning for a lisp routine, without any luck. I'm trying to draw a pline with a pre determined width (5') and be able to draw unlimited line segments then automatically fillet with a pre determined radius (5').
I wrote this generic macro: ^C^CPLINEWID;5;PL;;FILLET;R;5;F;P;LAST; to save SOME time but I want unlimited line segments. Can this be modified or would a lisp be the better route to go?
I wrote this generic macro: ^C^CPLINEWID;5;PL;;FILLET;R;5;F;P;LAST; to save SOME time but I want unlimited line segments. Can this be modified or would a lisp be the better route to go?
AutoCAD Visual LISP / AutoLISP :: Labeling Polyline Areas
May 4, 2011
Code below, for labeling polyline areas
It works great for what i want, with 2 exceptions the text is to small and the label is not inserted at the centroid of the polyline, rather it is placed outside the polyline.
i am able to increase the text style by adjusting the dimscale before i run the command, however it would be good if the program could do that automatically, i would like the text to be about 300 units high, and for the label to be placed at the centroid of the polyline
(defun C:AT ( / ss i)
It works great for what i want, with 2 exceptions the text is to small and the label is not inserted at the centroid of the polyline, rather it is placed outside the polyline.
i am able to increase the text style by adjusting the dimscale before i run the command, however it would be good if the program could do that automatically, i would like the text to be about 300 units high, and for the label to be placed at the centroid of the polyline
(defun C:AT ( / ss i)
AutoCAD Visual LISP / AutoLISP :: Divide And Measure Between Polyline
Aug 1, 2012do you know command or lisp that will do new pollyline between two polyline on 1/3 or 1/4 space between them.
I need sommething that would be faster,know is use measure on pollilines then i draw between horizontall polylines on verteks or point new pollyline and then divide it on 4 or 3 parts.
I need sommething that would be faster,know is use measure on pollilines then i draw between horizontall polylines on verteks or point new pollyline and then divide it on 4 or 3 parts.
AutoCAD Visual LISP / AutoLISP :: Arcs To A Segmented Polyline?
Apr 17, 2012i.e. one that would apply best fit lines and arcs to a segmented polyline?
AutoCAD Visual LISP / AutoLISP :: Vertices Of A Polyline Segment
Dec 18, 2011I have to intersect polylines 'POLYLINE' and 'LWPOLINE' with a line and get all the angles of all segments of the polyline that are intersected.
To do this I used a loop that monitors all the vertices of each polyline to find the two vertices of the polyline segment that intersects the line. Unfortunately, these polylines have thousands of vertices and the processing done in this way takes too long.
With the vlax-curve-getClosestPointTo I could very quickly find the vertex of the polyline closest to that intersected with the line, but I need to find the other vertex of the polyline segment to determine the angle of this.
Another question: is there a quick function that returns the exact point of intersection of two curves (e.g. A line and a polyline, or a line and a circle?
To do this I used a loop that monitors all the vertices of each polyline to find the two vertices of the polyline segment that intersects the line. Unfortunately, these polylines have thousands of vertices and the processing done in this way takes too long.
With the vlax-curve-getClosestPointTo I could very quickly find the vertex of the polyline closest to that intersected with the line, but I need to find the other vertex of the polyline segment to determine the angle of this.
Another question: is there a quick function that returns the exact point of intersection of two curves (e.g. A line and a polyline, or a line and a circle?
AutoCAD Visual LISP / AutoLISP :: Curve From Polyline Segments
Apr 13, 2012I´m looking for opportunities to can modify a polyline with 4 or more segments in a polyline with arc. I think it´s possible to pick start and end segment first and than all straight segments to will be in arc segments.
AutoCAD Visual LISP / AutoLISP :: Ribbon Polyline Command
Jul 29, 2013Creating a ribbon for Partial Customization files in the CUI, and I am trying to setup some buttons for existing polylines for example underground electric and overhead electric. When writing the macro what are some ideas for creating a polyline with the proper linetype for that particular object rather than changing the layer in layer properties dialogue.
AutoCAD Visual LISP / AutoLISP :: Round Down Area Of Polyline
May 8, 2013I have a closed polyline that i can add the area to via a field in mtext using the options under area. I would like the area to always be rounded down to the nearest square meter. Is the a way to do this via the acfields.fdc file?
AutoCAD Visual LISP / AutoLISP :: Attributes Contained Within A PolyLine
Oct 11, 2011I have to go through quite a few drawings and extract the attribute vales of the whole drawing and then a subset contained within a couple of polylines.
The whole drawing is Ok as I can use at out or the data extraction, but its the ones contained within a polyline. How do I do that?
The whole drawing is Ok as I can use at out or the data extraction, but its the ones contained within a polyline. How do I do that?