CAD Forum - Database of tips, tricks and utilities for AutoCAD, Inventor and other Autodesk products [www.cadforum.cz]
CZ | EN | DE
Login or
registration
  Visitors: 10728
RSS channel - CAD tips RSS tips
RSS discussions

Discussion Discussion forum

 

HelpCAD discussion

 
CAD Forum - Homepage 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.

How to post questions: register or login, go to the specific forum and click the NEW TOPIC button.
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Topic Closedmacro linetype

 Post Reply Post Reply
Author
jim78b View Drop Down
Groupie
Groupie


Joined: 17.May.2012
Location: Italy
Using: 2013 mech
Status: Offline
Points: 31
Direct Link To This Post Topic: macro linetype
    Posted: 26.Feb.2018 at 09:12
hello i want to draw a line on a layer and then return to previously layer 0 with byclok color is it possible i post a macro that don't work totally

^C^C_clayer AM_4;
^C^C_color BYLAYER;
^C^C_linetype;
Amzigzag;;^C^C_pline;;

i can not know how to return to layer"0" and set it the color to bycolor

Back to Top
jim78b View Drop Down
Groupie
Groupie


Joined: 17.May.2012
Location: Italy
Using: 2013 mech
Status: Offline
Points: 31
Direct Link To This Post Posted: 26.Feb.2018 at 12:27
I modified

^C^C_clayer AM_4;^C^C_color BYLAYER;
^C^C-linetype;S AMZIGZAG;;
^C^C_PLINE;\\;layerp;

^C^C_clayer 0;^C^C_color BYBLOCK;^C^C-linetype;S BYLAYER;;

but is incorrect because permit to draw a single line and can not repeat the command
Back to Top
Kent Cooper View Drop Down
Senior Member
Senior Member


Joined: 12.Mar.2013
Location: United States
Using: AutoCAD2020, 2023
Status: Offline
Points: 616
Direct Link To This Post Posted: 27.Feb.2018 at 17:20
You would need to use something like an AutoLisp routine rather than a command macro, to allow running a command with an unknown number of User inputs before going on to reset things like current properties.  If you're using the Mechanical overlay program, I assume you have full AutoCAD underlying that [not AutoCAD LT that doesn't have AutoLisp capability].  Is that correct?  If so, an AutoLisp routine could be written and defined as a command name, and wherever you have that macro [such as in a Tool Palette item] you could put the command name instead.
Back to Top
jim78b View Drop Down
Groupie
Groupie


Joined: 17.May.2012
Location: Italy
Using: 2013 mech
Status: Offline
Points: 31
Direct Link To This Post Posted: 28.Feb.2018 at 09:09
YES PALETTE item i prefer! thanks i want this because there is a graphical glitch in autocad mech2013 when i start amzigzag line
Back to Top
Kent Cooper View Drop Down
Senior Member
Senior Member


Joined: 12.Mar.2013
Location: United States
Using: AutoCAD2020, 2023
Status: Offline
Points: 616
Direct Link To This Post Posted: 28.Feb.2018 at 19:16
Something like this should do it [in simplest terms, untested]:
 
(defun C:AMZP (/ clay celt cec); = AMZigzag Polyline [call it something else if you like]
  (setq clay (getvar 'clayer) celt (getvar 'celtype) cec (getvar 'cecolor))
  (setvar 'clayer "AM_4")
  (setvar 'celtype "AMZIGZAG")
  (setvar 'cecolor "BYLAYER")
  (command "_.pline"); leave you in the command
  (while (> (getvar 'cmdactive) 0) (command pause)); accept User inputs until command is ended, then:
  (setvar 'clayer clay)
  (setvar 'celtype celt)
  (setvar 'cecolor cec)
)
 
That would set the Layer and current-entity Color and Linetype back to what they were when you called the command, not necessarily to Layer 0 and ByLayer and/or ByBlock as in your original code.  But it could be altered to force them to specific settings, whether or not those were current when it was called -- that would eliminate the variables in the above code.
 
It requires that the Layer and the Linetype do already exist in the drawing, but it could be altered to find out, and do something about it if necessary.
 
Load that [do you know how?], then, in a Tool Palette item, put simply:
 
^C^CAMZP
 
but you also have the option to just type in the command name AMZP [or whatever you call it], instead of being required to go to the Tool Palette for it every time [another advantage of defining a command name like this].
 
[I do wonder why you're assigning an override linetype, rather than assigning that linetype to the AM_4 Layer and using ByLayer.]
Back to Top
jim78b View Drop Down
Groupie
Groupie


Joined: 17.May.2012
Location: Italy
Using: 2013 mech
Status: Offline
Points: 31
Direct Link To This Post Posted: 28.Feb.2018 at 19:21
thanks you are the best!!!
Back to Top

Related CAD tips:


 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down



This page was generated in 0,477 seconds.