MACRO for producing a polyline with a specific linetype scale not working correctly

MACRO for producing a polyline with a specific linetype scale not working correctly

Anonymous
Not applicable
1,451 Views
9 Replies
Message 1 of 10

MACRO for producing a polyline with a specific linetype scale not working correctly

Anonymous
Not applicable

Hi all,

I'm trying to create a Macro that will create a polyline with a linetype scale specified by the system variable LTSCALE, so far all I've been able to do is stall my autocad and I'm not too sure where I'm going wrong. This is my first time using DIESEL code so apologies if I'm using it incorrectly

^C^C -pline\ w; 0.8; 0.8;; -chprop;l;;s;$M=$(if, $(=, $(getvar,ltscale), 1), 2 [,$(if, $(=, $(getvar,ltscale), 50), 0.04 [,$(if, $(=, $(getvar,ltscale), 100), 0.02 [,$(if, $(=, $(getvar,ltscale), 200), 0.01 [, 0.005])])])]);

if it's relevant I'm 'calling' the macro from the Run Script... pallette command.

 

Thanks for any advice

0 Likes
Accepted solutions (1)
1,452 Views
9 Replies
Replies (9)
Message 2 of 10

cadffm
Consultant
Consultant

This macro is totally wrong (5 character is th blank = 1. fail and a lot more follows..)

after PLINE command is not ENTER; and so on.

Is it the right code you talk about?, not a copy&paste issue

 

 

Sebastian

0 Likes
Message 3 of 10

ВeekeeCZ
Consultant
Consultant

Are you on LT? Any reason why DIESEL?

Can we use a LISP?

0 Likes
Message 4 of 10

Anonymous
Not applicable

Apologies that was an incorrect copy

^C^C -pline;\w;0.8;0.8;-chprop;l;;s;$M=$(if, $(=, $(getvar,ltscale), 1), 2 [,$(if, $(=, $(getvar,ltscale), 50), 0.04 [,$(if, $(=, $(getvar,ltscale), 100), 0.02 [,$(if, $(=, $(getvar,ltscale), 200), 0.01 [, 0.005])])])]);
0 Likes
Message 5 of 10

Anonymous
Not applicable

@ВeekeeCZ I'm using AutoCAD 2018, as far as I'm aware DIESEL was the easiest way to write an if statement macro, if it's not feasible then I'll try LISP

0 Likes
Message 6 of 10

cadffm
Consultant
Consultant

 

@Anonymous 

This is also a wrong string, try another source ctrl+c and paste it here direct as text (ctrl+v)

 

 

 

-chprop ? Is not an AutoCAD command.

So, now i am very sure:

You wrote: "I'm trying to create a Macro"

 

But if the 5.character is wrong and the macro over 200characters long, this has nothing to do with "build a macro".

You have to write a macro step by step.

^C^C [ESC][ESC] works, so you can use the first 4 characters.. and add the next step, start the pline command: PLINE<enter>

^C^CPLINE;

works? and the next step, 1. point

^C^CPLINE;\

works? and the next step, option w for witdh, start 0.8,  end 0.8: w;0.8;0.8;

^C^CPLINE;\w;0.8;0.8;

works? Okay

 

Now you have to set a second point for the pline, not a problem: \

But the macro needs to know ALL user points for the polyline! This is the nature of macro and polyline command.

If you want to make anything after the polyline command, you have to define ALL interactive input.

This will work only if you need a fix number of vertecs. Is this the case?

 

for esxample, THREE vertecs for the pline:

^C^CPLINE;\w;0.8;0.8;\\;

 

I'am waiting for your response

Sebastian

0 Likes
Message 7 of 10

Anonymous
Not applicable

@cadffm By '5' character I assume you mean $? this is a character used in Macros when you want to use DIESEL code in your macro as described here.

-chprop is a command in autocad that allows you to change the properties of the selected geometry in the command line

0 Likes
Message 8 of 10

cadffm
Consultant
Consultant

@Anonymous wrote:

@cadffm By '5' character I assume you mean $? this is a character used in Macros when you want to use DIESEL code in your macro as described here.

-chprop is a command in autocad that allows you to change the properties of the selected geometry in the command line


Please look what you posted above, character 1-4 is: ^C^C

and the 5. is a BLANK! = [SPACE]

 

My knowledhe about macros, also with diesel are not bad, so i don't need link for autocad commands, macro or diesel.

 

-CHPROP  is NOT an autodesk command, CHPROP or _CHPROP as a command to change the properties

also -PLINE is not an autoCAD command

 

Whatever, the posted macro string has nothing to do with trying to build a macro,

thats why i guess you are a beginner to the topic (and all the problems are not DIESEL related)

Sebastian

0 Likes
Message 9 of 10

ВeekeeCZ
Consultant
Consultant
Accepted solution

I think that DIESEL is just a wasted time of yours. Not at all saying it's completely useless but...

 

This seems pretty simple too. And the result/performance would be very likely much better.

 

 

(defun c:PLINESC ( / w c l)
  
  (setq w (getvar 'plinewid)
	c (getvar 'celtscale)
	s (getvar 'ltscale))
  
  (setvar 'plinewid  0.8)
  (setvar 'celtscale (cond ((= s 1) 	2.)
			   ((= s 50)  0.04)
			   ((= s 100) 0.02)
			   ((= s 200) 0.01)
			   (0.005)))
  
  (command-s "_.PLINE")
  (setvar 'plinewid  w)
  (setvar 'celtscale  c)
  (princ)
  )

 

 

 
Message 10 of 10

Kent1Cooper
Consultant
Consultant

@ВeekeeCZ wrote:

....

....
  (setvar 'celtscale (cond ((= s 1) 	2.)
			   ((= s 50)  0.04)
			   ((= s 100) 0.02)
			   ((= s 200) 0.01)
			   (0.005)))
....
 

That much could be replaced by just:

  (setvar 'celtscale (/ 2 s))

except for the 0.005 none-of-the-above value, but instead of that it would return a value with an actual relationship to the linetype scale, whatever that is, the same as the relationship to those few specific values, instead of a single  arbitrary value for any  other linetype scale.

 

And, given that, there's really no need for the 's' variable, since it would be used only once.  You can skip saving that, and use just:

  (setvar 'celtscale (/ 2 (getvar 'ltscale)))

 

Kent Cooper, AIA
0 Likes