AutoCAD Visual LISP / AutoLISP :: How To Return Entity Name Largest Polyline Of A Selection Set

Oct 8, 2013

I need to return the entity name of the largest (longest closed) polyline in a selection set. At this point I have no trouble creating the selection set and even getting the area of the boundingbox, which is not the most accurate way to find the true size, but it's a start. The part that has me stumped is: if I iterate through the selection set, then how can I compare one to the other when I have access to the current entity. I've been staring at examples of lambdas but it seems to me that iterating through the selection set is going about it wrong in the first place. 

Below is my current code with a remaining issue. I can return the largest area of the polylines (no good for more than two entities in selection set), but I do not know how to return the entity name:
 
(IF (> (SETQ SS (SSGET "x" '((0 . "*POLYLINE") (8 . "POOL") (-4 . "<OR") (62 . 5) (62 . 256) (-4 . "OR>")))) 1 ) (PROGN (SETQ a (1- a) ent (CDR (CAR (SSNAME ss a))) en2 (CDR (CAR (SSNAME ss (1- a)))) ar1 (APPLY '* (LIST (LAMBDA (ent) (VLAX-INVOKE-METHOD (VLAX-ENAME->VLA-OBJECT ent) 'getboundingbox 'minpt 'maxpt) (SETQ pt1 [code]......

View 9 Replies


ADVERTISEMENT

AutoCAD Visual LISP / AutoLISP :: Return Name Of Different Folders?

May 15, 2013

The following gives me the first folder string, with no back-slashes, that the drawing exists in.

(setq FirstFolder
 ((lambda (/ tmpDir tmpPos)
 (substr
 (setq tmpDir (getvar "dwgprefix"))
 (+ 2 (setq tmpPos (vl-string-search "\" tmpDir)))
 (- (vl-string-search "\" tmpDir (1+ tmpPos)) (1+ tmpPos))))))

Is there a way to find the name of the second folder?

Is there a way to find the name of the third folder?

The string length of the characters for each of the first, second, third (and so on) folders are different, which means I can't count character using the "substr" function.

View 8 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Return Last Command

Jun 27, 2013

Trying to diable the spacebar = (return last command) function!

commandlinehide does te job in the working interface, but a space in scriptmode (in the filename e.g.) still repeats last command!

View 9 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Reduce Polyline With Multiple Vertices To Single Polyline

Jun 7, 2012

I 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?

View 4 Replies View Related

AutoCAD Visual LISP / AutoLISP :: 3D Polyline To Polyline To Spline With Max

Sep 21, 2013

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

View 5 Replies View Related

AutoCAD Visual LISP / AutoLISP :: GetBoundingBox Return Bad Results For Z Value

Aug 5, 2013

The lisp routine displays point values of a boundry (window) of an object using the vla_getBoundingBox.

The concept of the routine is to select any object and return two Point window value.

This routine works, but I noticed the Z point is changing depending on the object type drawn in 2d space elevation 0.0.

Test: Open a new drawing.  Set the snap value to 1.0 just to make is easy to see values.

Draw three objects: A horizonal line, A Rectangle and Arc.

Load the gbb.lsp and run it, gbb

Select all three objects and notice the results.

It appears that objects the have an curve change the Z value (very little), but Z should be zero.

Try it with a polyline and then PEdit and FIT and re-check the Z value.

View 5 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Return Coordinates Of LWPOLYLINE

Oct 21, 2013

I recently wrote a lisp routine that was supposed to get the 4 coordinates of a rectangle (LWPolyline).  It worked fine in *MY* tests.  But when someone else ran it, the routine operated as though the order of the points had been rearranged.

How can I get the points AND the order in which they belong?

Here's a sketch to show you what I mean.  As part of my troubleshooting, I had a lisp routine draw a new pline using the points gathered by my first routine.  The result of that on the left.  On the right is the result of that when someone else runs the two routines.

Here's the code I used to get the points.

(defun getplinepointlist(ename)
(setq ent(entget ename))
(setq ptlist (list))
(while (setq pt(cdr(assoc 10 ent)))
[code].......   

View 6 Replies View Related

AutoCAD Visual LISP / AutoLISP :: How To Determine Existence Of Entity

Oct 10, 2013

I have a specific need to determine if an entity is existing or not so that I can either make changes to or create the entity. I'm trying to do this while referring to the entity by it's handle. Below is my code this far but it doesn't work.
 
(IF (AND (SETQ HNDL (VLAX-LDATA-GET "TB" (STRCAT PLN "PLAN"))) (NOT (VLAX-ERASED-P (VLAX-ENAME->VLA-OBJECT (HANDENT HNDL)))) ) (PROGN ;;| DO SOMETHING WITH THE EXISTING ENTITY ) (PROGN ;;| MAKE THE ENTITY
(vlax-ldata-put "TB" (strcat PLN "PLAN") (CDR (ASSOC 5 (entget (entlast))))) ))

I ran the program and the handle was stored, then I deleted the entity and ran the code again and this is the error I get:

; error: unable to get ObjectID: nil

This VLISP stuff sometime has unpredictable hoops to jump through first, so I wondering if this is the case here.

View 3 Replies View Related

AutoCAD Visual LISP / AutoLISP :: How To Draw Text Entity In 3D

Apr 29, 2012

how to draw a text entity in 3d, where I know the 3d ins point, and the plane it should be flat to.

I have not drawn text or inserted blocks programatically before where the plane they lie on is not flat.

I have done it before by setting a ucs and drawing stuff, but now I want no switches of UCS involved.

[URL]

View 2 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Retrieving Xdata From An Entity?

Mar 29, 2012

How can i build a selection set of all circles  and then retrieve the xdata attached to them? 

View 9 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Snapang Within MVBlocks / ADT Entity

Aug 19, 2013

How do I get the angle of an Mvblock/wall or any other ADT entity to use in a lisp routine to set Snapang?

View 4 Replies View Related

AutoCAD Visual LISP / AutoLISP :: How To Cancel Return Value Of REPEAT Command

Jan 10, 2013

I use the Repeat command with an index, and when it exits, it writes the last index.

I cannot move it to a new line,nor cancel it.

If i insert a (princ "") inside the loop it moves it to a new line, but also all  the outputs of the loop get extra line spaces

View 1 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Access Text In MTEXT Entity

Dec 29, 2012

I am wanting to use autolisp to access the text in a MTEXT entity.  assoc(1) gives me the first bit of text, but not the rest.Is there a way to use assoc to access each of a number of matches or do I need to write my own routine to find all the 1's?

View 5 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Find Position XYZ And Rotation XYZ Of Each Entity?

Jul 13, 2011

finding each objects Position XYZ and Rotation XYZ using LISP.  It looks like position is a pretty easy one but rotation data is a bit elusive.  

View 9 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Get Point On Entity But Ignore Ones At 0.0 Elevation

Sep 15, 2011

I need to let the user pick on an entity to get an elevation.

I was using getpoint, with osmode set to nearest, but it allows them to pick 2d items under the 3d items I want picked.

Without doing fancy laer manipulation to turn off 2d stuff, are there any tricks to avoid snapping on the 2d item?

I am thinking I might do an entselp, then try again at same point until i get a 3d one (non 0.0 z coord).

[URL]

View 7 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Point Entity In A Hatch Pattern

Nov 29, 2012

Is it possible to include a point entity (rather than a zero-length line as in the standard SQDOTS pattern) in a custom hatch pattern?

If so what's the exact format of the line in the .pat file that defines the point?

View 9 Replies View Related

AutoCAD Visual LISP / AutoLISP :: How To Retrieve Length Value Of Single Entity

Feb 27, 2012

When we launch the list command, the Area system variable holds the area value of the selected shape.

How to get the length value into an Autolisp program to use it?

View 3 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Retrieving Entry From Entity Association List

Nov 13, 2013

presuming I have a selection set of different entities, that might have different linewight.

The code that is responsible for this property is 370

370Lineweight enum value. Stored and moved around as a 16-bit integer.not omitted from here  

I need to make all of the entities have the same layer, and to make sure the each entity has the "ByLayer" lineweight.

The problem that I encountered, is the lineweight changement.

This is the colution that I came with, but it doesn't work for me:

(defun c:test () (setq en (car (entsel))) (setq el (entget en)) (setq el1 '()) (setq indx -1) (repeat (length el) (setq indx (1+ indx)) (if (/= (nth indx el) (assoc 370 el)) (setq el1 (cons (nth indx el) el1)) ) ) (setq el el1) (entmod el) (princ) )

 Having tested it in different ways, it looks like at the end, el1 represents the association list that I want my object to have, but it doesn't want to update.

View 9 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Extended Data On 2D Entity - Filter List

Apr 30, 2012

I use extended data on 2d entity in AutoCAD 2010. In a lisp program, I have filtered with extended data selection. Filters work with entity like: line, polyline and Mline but with insert entity it don’t work.

The end get result for a block :

((-1 . <Nom d'entité: 7ffffbe7d90>) (0 . "INSERT") (330 . <Nom d'entité: 7ffffb039f0>) (5 . "18CA91") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "Fam_POTEAU_ROND_INSERT_021") (100 . "AcDbBlockReference") (2 . "POTEAU_ROND") (10 155239.0 -100209.0 0.0) (41 . 16.05) (42 . 16.05) (43 . 16.05) (50 . 0.0) (70 . 0) (71 . 0) (44 . 0.0) (45 . 0.0) (210 0.0 0.0 1.0) (-3 ("CREEMET000" (1000 . "Fam021") (1040 . -14.0) (1040 . 434.0) (1071 . 0)) ("CREEMET001" (1071 . 2) (1071 . 3) (1071 . 0)) ("CREEMET014" (1000 . "Poteau rond mixte (a completer)")) ("CREEMET002" (1000 . "_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_-1_-1_-1"))))

The filter list use :

((-4 . "<OR") (2 . "POTEAU_ROND*") (-4 . "OR>") (-3 ("CREEMET002" (1000 . "_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_0_-1_-1_-1"))))

View 3 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Extended Entity Data Lost In Files

Jan 2, 2013

Just recently I have noticed a Major problem occurring with Xdata.  My programs that i use XDATA storage in work fine until you save the drawing.  When you call the file back up the Xdata is gone the only thing in the xdata is NameSpace value.  Is this related somehow to a Windows update?

View 2 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Delete Vertex From 3D Pline Without Making New Entity?

Dec 6, 2007

I have a program that makes 3d polylines from various data. That 3d pline then gets added to a civil 3d surface as a breakline. I want to modify the pline with my program, but preserve the handle, as I think that is what C3D uses to decide if its part of the surface. I tried this as a sample with no luck:

;DELETE 3RD VERTEXT FROM 3D PLINE
(DEFUN C:T3 ( / EN ENAME ENT ENTL)
;GET 3D PLINE
(SETQ ENT (ENTSEL "
Select 3D Pline:")

[Code] .....

I know you can modify a vertex, but what about add and delete with entmake and entmod? I also considered using activex for this task, but you can only add verticies from what I could tell in the object browser of VBA, not delete them.

What I will be doing is deleting all the verticies and adding back the correct ones. Or if there was a way to transfer a handle to a new entity after deleting the old, that would suffice too.

View 9 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Return A List Of Strings Of Layout Tabs In Drawing

Mar 6, 2013

(layoutlist) ... returns a list of strings of the layout tabs in the drawing.I've used this ages... Isn't it a core lisp function, or is it coming from express tools or somewhere else?

View 5 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Return To Calling Function After Trapping Error In Subroutine

Mar 13, 2012

I've got a subroutine that gets the centroid of a closed polygon (lwpoly).  It appears to fail if the polygon has any zero length line segments.  I've added a trap that catches the error and "highlights" the offending polygon, but it stops there and does not return to the main function that called the subroutine.  Is there a way to get back to the main function from the trap?

Here's the subroutine (original function by _gile (Autodesk LISP Forum 9-18-2006):

(defun return-centroid (lwpoly space / obj Region Centroid)
(setq *error* trap1)
(setq obj (vlax-ename->vla-object lwpoly))
(setq Region (vlax-invoke space 'addRegion (list obj)))
(setq Centroid (trans (vlax-get (car Region) 'Centroid) 1 0))
(vla-delete (car Region))

[code]....

View 2 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Change Color And Linetype Of Xref Nested Entity

Aug 22, 2012

I have a Lisp that I have been working on with some folks in the office, and i feel like i am close, but i am not getting the cigar. The idea would be to have the lisp allow the user to select a nested x-ref entity, and change the color and linetype of the selected layer, similar to the old "LAP" command (I know it is a dinosaur, but I still miss it). I seem to be doing swimmingly, code I have quasi-plagiarized. It seems to crap out where i try to pass the selected linetype back to the layer. I get the nastygram "Command: ; error: no function definition: GETLINETYPE" right after selecting the linetype from the dialog.

Code below...

x(defun c:CX (/ Sel EntList DataList cnt Num ClrNum EntData)
(if (setq Sel (nentsel "
Select object to change layers color and linetype: "))
(progn

[Code]...

HP Elitebook Workstation
Windows 7

View 6 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Function To Print Out Entire List Of Selected Entity?

Oct 28, 2011

I am looking for a function to print out the entire entity list of the selected entity...

so... walking down through the entity data... print out what it finds... any time it encounters an entity name... then do an entget and print that out too.

View 8 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Select Entity With Options To Type In Text / Pick Point

Nov 6, 2013

I am looking for some code that would allow me to select a MTEXT Entity - or other entity -  (as the DEFAULT option) but also to allow me to type in some text manually or to pick a point in the drawing. Something that would present the user with:

"Select an object or [P to pick a point]"  or

"Select MTEXT or [M to type].

I can write some code to type in text manually as the default option and get the second option to select entity using get string and then write some condition of if code but I don't know how to do it having entsel as default option.

View 3 Replies View Related

AutoCAD Visual LISP / AutoLISP :: ANGTOS Return Accurate Result For Number If Decimal Places Requested

Jan 5, 2012

I work with ANGTOS and ANGTOF quite a bit.  I'm working with latitude and longitude conversions in MAP 3D for an application where accuracy is top priority.  Most of the time ANGTOS (and RTOS, for that matter) return an accurate result for the number if decimal places requested, but then I run into a situation like this:

Command:
(angtos (angtof "120.0") 1 16)
"119d59'59.999999999949""

I got it to return properly by specifying only 13 decimal places, but the result makes conversion between coordinate systems inaccurate.

View 1 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Remove A Selection Set From A Selection Set

Nov 15, 2013

I've created a lisp that draws the boltholes of a pipe flanges, using the correct number of holes, at the correct diameter at the correct bolt-hole diameter and then rotates.  Everything works seamlessly, when i do just one flange.  But I've discovered that fewuently there will be mulitple times when a user will have to perform the command.

So the idea I had was to do the following:

Select all circles with     (setq CirclesFirst (ssget "X" (list (cons 0 "CIRCLE"))))

Go through the code to create the new circles.

Select all circles with     (setq Circles (ssget "X" (list (cons 0 "CIRCLE"))))

Remove selection set "CirclesFirst" from "Circles".

But what for some reason (command "_.select" Circles "R" CirclesFirst "") does not work.

View 9 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Get Enames Of Each Polyline

Apr 26, 2013

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

View 9 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Sum Of Polyline Lengths

May 21, 2012

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

View 8 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Change Z Value Only On 3D Polyline

Aug 23, 2012

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

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved