Inserting blocks from ribbon to scale

Inserting blocks from ribbon to scale

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

Inserting blocks from ribbon to scale

Anonymous
Not applicable

Is anyone able to help?

When we setup the Ribbon a few years ago I wanted the block’s to come into the drawing to the scale I was working in, 1:100 or 1:200 etc….

So the cannoscale set 1:100 the block was coming in at 1.

1:200 = 2

1:50 = 0.5

Etc…

With the change from AutoCAD 2016 to AutoCAD 2018 & 2020 a command in the ribbon doesn’t work.

 

So adding the insert_to_scale worked but now its not.

I get this error.

 

error: no function definition: INSERT_TO_SCALE

 

Do you know how to fix it?

 

Refer image to see part of the Ribbon setup and the Macro.

 

Thank you for your help

0 Likes
1,001 Views
9 Replies
Replies (9)
Message 2 of 10

ВeekeeCZ
Consultant
Consultant

The function INSERT_TO_SCALE has to be defined by a LISP which would be loaded on startup. So search the computer for this LISP and add it into Startup Suite for automated load. Look HERE  for more details.

 

0 Likes
Message 3 of 10

Anonymous
Not applicable

Thank you for your reply, Im trying to find that lisp, the only thing is our department has split away from the greater company and now its hard to get any info from them. I know they did something in the back ground to get this to work for us when I set it up a few years ago. Ill keep looking. 

0 Likes
Message 4 of 10

Sea-Haven
Mentor
Mentor

You will have to write it again, (getvar 'cannoscale) = 1:100 so need the scale divide by 100.

 

The png has 3 items block name is obvious not sure about the others.

0 Likes
Message 5 of 10

Anonymous
Not applicable

Hi  sea.haven  

Are you able to help with? 

A macro that inserts a block by dividing the cannoscale by 100?

I would be very grateful thank you 

0 Likes
Message 6 of 10

Sea-Haven
Mentor
Mentor

This is the start the cannoscale bit.

 

(setq cansc (getvar 'cannoscale))
(setq pos (vl-string-search ":" cansc)) ; note character found starts at 0
(setq sc (/ (atof (substr str (+ pos 2) )) 100.0)) ; substr starts at 1

(setq pt (getpoint "Pick insertion point"))
(command "-insert" blockname pt sc "" 0)
0 Likes
Message 7 of 10

Jonathan3891
Advisor
Advisor

@Sea-HavenI played with your code but couldn't get it to work.

 

This returned 1 no matter what the "CANNOSCALE" was set to

(setq pos (vl-string-search ":" cansc))

This is my take at it.

 

  (setq cAnno (getvar 'cannoscale))
  (setq cAnnoVal (/ 1 (getvar "cannoscalevalue")))
  (setq Sc (/ cAnno 100))

Jonathan Norton
Blog | Linkedin
0 Likes
Message 8 of 10

cadffm
Consultant
Consultant

"This returned 1 no matter what the "CANNOSCALE" was set to"

 

Only if you have ":" as part of the current annoscale name

and only if only one char is front of.

Set scale 10:1 current and try it again 😉

 

That why it is a (too) simple solution.

1. The simple sample way in this thread can not handle "2:4" or "4:1"

2. The annoscale NAME has nothing to do with the real factor, so the canme can be "DOG" or "55:3" and the scale is 4:5

 

 

 

 

Sebastian

0 Likes
Message 9 of 10

Jonathan3891
Advisor
Advisor

Thanks @cadffm, I only checked it with a few preset scales.

 

Try this out, but if your scale is anything like what @cadffm described then it wont work.

(defun c:insert_to_scale (/ oLayer cAnno iScale Bname Pnt Lname)
  (setq oLayer (getvar 'clayer)
	cAnno (/ 1 (getvar 'cannoscalevalue))
	iScale (/ cAnno 100)
	Bname (getstring t "\nSpecify block name: ")
	Pnt (getpoint "\nSpecify insertion point: ")
	Lname (getstring t "\nSpecify layer name: ")
	)
  (if (tblsearch "LAYER" Lname)
    (progn
    (command "-layer" "s" Lname "")
    (command "-insert" bname "_scale" iScale "_rotate" 0 Pnt)
    )
    (princ "\nLayer Invalild!")
    );if
  (setvar 'clayer oLayer)
  (princ)
  )

Jonathan Norton
Blog | Linkedin
Message 10 of 10

cadffm
Consultant
Consultant

@Jonathan3891  schrieb:

Thanks @cadffm, I only checked it with a few preset scales.

 

Try this out, but if your scale is anything like what @cadffm described then it wont work.

Oh no, with the cannoscalevalue instead of the CANNOSCALE it should work everytime, because this is the real factor an not only a (useless) name.

Or i am wrong now?

 

@Jonathan3891  schrieb:
	cAnno (/ 1 (getvar 'cannoscalevalue))
	iScale (/ cAnno 100)
	

or without the canno line

iScale (/ 0.01 (getvar 'cannoscalevalue))

 

and shortcodefreaks never saves values for only 1x use, they add (/ 0.01 (getvar 'cannoscalevalue)) directly in the command-expression and removes canno and iScale from the code,

but i prefer to use the (setq iscale ..) , it's easier to read the code (or me)

 

Command and osnaps, add a osnaps handling:

Make sure your command ignore osnaps (setvar 'osnapcoords 1) first or add (un)snap mode NONE

(command "-insert" bname "_scale" iScale "_rotate" 0 "_none" Pnt)

 


@Jonathan3891  schrieb:

Thanks @cadffm, I only checked it with a few preset scales.

 

Try this out, but if your scale is anything like what @cadffm described then it wont work.

  (if (tblsearch "LAYER" Lname)
    (progn
    (command "-layer" "s" Lname "")
    (command "-insert" bname "_scale" iScale "_rotate" 0 Pnt)
    )
    (princ "\nLayer Invalild!")
    );if

Suggestion:

(if (snvalid Lname)

    (command "_.-LAYER" "_th" Lname "_make" "Lname"  "_.-insert" bname "_scale" iScale "_rotate" 0 "_none" Pnt)

    (princ "\nLayername invalid!")

)

And much better: Ask for Lname so long the user input is not valid

and accept a "just enter" hit as "current Layer"

 

--

 

>"(command "-insert" bname "_scale".."

It is useless to use a underscore for the options if you call the command without

and it is useless if you don't use it in the whole code,

unless it will break in most of the other (none english) versions.

 

 

Kudo4u

Sebastian

0 Likes