Over 1.106.000 registered users (EN+CZ).
AutoCAD tips, Inventor tips, Revit tips, Civil tips, Fusion tips.
Try the new precise Engineering calculator.
New AutoCAD 2026 commands and sys.variables and env.variables,.
Discussion forum
?CAD discussions, advices, exchange of experience
CAD discussion forum - ask any CAD-related questions here, share your CAD knowledge on AutoCAD, Inventor, Revit and other Autodesk software with your peers from all over the world. To start a new topic, choose an appropriate forum.
Please abide by the rules of this forum.
This is a peer-to-peer forum. The forum doesn't replace the official direct technical support provided by ARKANCE for its customers.
How to post questions: register or login, go to the specific forum and click the NEW TOPIC button.
|
Post Reply
|
Page 12> |
| Author | ||
kameron1967
Groupie
Joined: 30.Jan.2011 Location: United States Using: autocad 2018 Status: Offline Points: 29 |
Topic: LISP ErrorPosted: 21.Feb.2011 at 22:11 |
|
|
Hi. Someone helped me with this, but I'm not able to get it to run. It has a syntax error.
[CODE]
(defun C:NEWL ();R-1
(vl-load-com);R-1 (setq PickItem (car (entsel "\nPick object for new layer: ")));R-1 (setq ObjLayer (cdr (assoc 8 (entget pickItem))));R-1 (setq ObjType (cdr (assoc 0 (entget pickItem))));R-1 (princ (strcat ObjLayer is layer name of " ObjType " selected"));R-1 (initget "N D V");R-1 (Setq LyrSuffix (getkword "\nEnter suffix type [N-PKG-1/D-PKG1/V-PKG-1]:"));R-1 );R-0 |
||
![]() |
||
HAWDesigner
Senior Member
Joined: 04.Aug.2008 Location: United States Using: AutoCAD R14, AutoCAD 2009, AutoCAD 2010 Status: Offline Points: 310 |
Posted: 21.Feb.2011 at 23:27 |
|
|
The initial error I got was "ERROR: malformed string on input".
By changing Line7 to the following, it cleared that error, but every time I enter a suffix type, I now get the error: "Invalid Option Keyword"
NOTE: You were missing a " (quote) between ObjLayer and is. Edited by HAWDesigner - 21.Feb.2011 at 23:29 |
||
|
--
R. Williams AutoCAD 2010 Certified Professional <!-- If all else fails hit F1 --> <<AutoCAD 2009 |
||
![]() |
||
kameron1967
Groupie
Joined: 30.Jan.2011 Location: United States Using: autocad 2018 Status: Offline Points: 29 |
Posted: 22.Feb.2011 at 01:43 |
|
|
Thanks. So if I wanted to create a new layer based on the entity that I selected (for instance a line on H-ROOM layer), how would I attach the modifier to that entity so that if I choose D for suffix, it will automatically create a new layer based on the entity so that the new layer would look like this: H-ROOM-D-PKG1? Thanks.
(Setq LyrSuffix (getkword "\nEnter suffix type [N-PKG-1/D-PKG1/V-PKG-1]:"))
Would it be something like this..?
(setq oLayers
(vla-get-layers
(vla-get-activedocument (vlax-get-acad-object)))) (if (not (tblsearch "LAYER" objlayer))
(progn (setq LyrNew (vla-add oLayers LYR)
LyrTab (vla-item oLayers sLYR) ) (vla-put-linetype LyrNew (vla-get-linetype LyrTab)) (vla-put-truecolor LyrNew (vla-get-truecolor LyrTab)) (vla-put-truecolor LyrNew (vla-get-truecolor LyrTab)) (vla-put-freeze LyrNew (vla-get-freeze LyrTab)) (vla-put-layeron LyrNew (vla-get-layeron LyrTab)) (vla-put-lineweight LyrNew (vla-get-lineweight LyrTab)) (vla-put-lock LyrNew (vla-get-lock LyrTab)) (vla-put-material LyrNew (vla-get-material LyrTab)) ;(vla-put-plotstylename LyrNew (vla-get-plotstylename LyrTab)) )) (setq ent (car(entsel)))
(setq nlayer (cdr (assoc 8 (entget ent))) ) (setq LyrNew (strcat LYR lyrsuffix)) Edited by kameron1967 - 22.Feb.2011 at 01:50 |
||
![]() |
||
HAWDesigner
Senior Member
Joined: 04.Aug.2008 Location: United States Using: AutoCAD R14, AutoCAD 2009, AutoCAD 2010 Status: Offline Points: 310 |
Posted: 22.Feb.2011 at 14:00 |
|
|
I'm not an expert on LISP yet, sorry. Finding syntax errors is about as far as my LISP abilities go. Perhaps CarlB can lend you a hand on this.
Good Luck!! |
||
|
--
R. Williams AutoCAD 2010 Certified Professional <!-- If all else fails hit F1 --> <<AutoCAD 2009 |
||
![]() |
||
Vladimir Michl
Moderator Group
Arkance Systems CZ Joined: 26.Jul.2007 Location: Czech Republic Using: Autodesk software Status: Offline Points: 2144 |
Posted: 22.Feb.2011 at 14:58 |
|
|
Yes, this is one of the ways how to do it. This LISP code seems to be mixed from several sources - the names of layer variables are mixed: objlayer, LYR, nlayer.
Assumes e.g. that objlayer is already filled with the old layer name.
|
||
|
Vladimir Michl (moderator)
ARKANCE - https://arkance.world - Autodesk Platinum Partner |
||
![]() |
||
kameron1967
Groupie
Joined: 30.Jan.2011 Location: United States Using: autocad 2018 Status: Offline Points: 29 |
Posted: 22.Feb.2011 at 18:00 |
|
|
yes, you're right. It was taken from various source. I need to somehow tie them all in so that whatever letter I choose, it appends the right suffix to the new layer that it will be creating. If anyone has a shortcut to creating a simple layer modifer, I'd love to see it. Basically, if N is chosen, it will add the -N-PKG1 in the new layer based on the entity selected. Thanks.
|
||
![]() |
||
CarlB
Senior Member
Joined: 16.Oct.2009 Location: United States Status: Offline Points: 321 |
Posted: 23.Feb.2011 at 02:06 |
|
|
OK since my name was mentioned..here's my take at a simple lisp..
|
||
![]() |
||
kameron1967
Groupie
Joined: 30.Jan.2011 Location: United States Using: autocad 2018 Status: Offline Points: 29 |
Posted: 23.Feb.2011 at 02:24 |
|
|
Thanks, CarlB. You're a savior!
|
||
![]() |
||
HAWDesigner
Senior Member
Joined: 04.Aug.2008 Location: United States Using: AutoCAD R14, AutoCAD 2009, AutoCAD 2010 Status: Offline Points: 310 |
Posted: 23.Feb.2011 at 15:26 |
|
|
Nice Carl, thanks for that. I hope I didn't throw you under the bus there.
![]() Here's something I noticed in v2009:
The code above results in an error if you select the value from the Drafting ToolTips. ![]() ... because it is entering the entire value instead of just the N, D, or V as the "(initget "N D V");R-1" requests. In order to prevent that error, I had to change the line to the following, but I know that doesn't fully explain what's going on.
Is there any way to have it both ways? Edited by HAWDesigner - 23.Feb.2011 at 15:27 |
||
|
--
R. Williams AutoCAD 2010 Certified Professional <!-- If all else fails hit F1 --> <<AutoCAD 2009 |
||
![]() |
||
kameron1967
Groupie
Joined: 30.Jan.2011 Location: United States Using: autocad 2018 Status: Offline Points: 29 |
Posted: 23.Feb.2011 at 17:48 |
|
|
CarlB - is there a way to make it so that the newly created layer of the entity that we selected retains that same layer information as the one entity that we selected? As of right now, it creates a new layer, but with default color and linetype. If we can specify the linetype and color associated to each modifier, that would work also. Thanks.
|
||
![]() |
||
Post Reply
|
Page 12> |
|
Tweet
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
This page was generated in 0,133 seconds.
![CAD Forum - tips, tricks, discussion and utilities for AutoCAD, Inventor, Revit and other Autodesk products [www.cadforum.cz] CAD Forum - tips, tricks, discussion and utilities for AutoCAD, Inventor, Revit and other Autodesk products [www.cadforum.cz]](/common/arkance_186.png)


LISP Error
Topic Options




CarlB wrote: