Hey, getting an error with this lisp it keeps saying invalid block name. It exists and if I were to do insert manually it works just fine. So what gives? Here's the line of lisp.
(command "insert" "Block name" pt "" "")
Solved! Go to Solution.
Solved by dbhunia. Go to Solution.
@Anonymous wrote:Hey, getting an error with this lisp it keeps saying invalid block name. It exists and if I were to do insert manually it works just fine. So what gives? Here's the line of lisp.
(command "_.insert" "Block name" pt "" "" "")
Try with above
@Anonymous Strange 🤔 , can you attach an example of your .dwg?
(command "_.Insert" "Block Name" pause 1 1 pause)
Its just a legend, I figured out the name issue. It doesnt need the quotes around it haha. However theres another issue, it wont insert. Obviously I dont have the syntax right but I dont know what I need to fix been monkeying around heres what I have so far. Getting a return of nil
(command "insert" blockName 4.3,6 "" "")
Hmm, these dont work either. The first one gets an invalid selection error thrown, and the second one returns nil and then asks to select objects??
@Anonymous wrote:Hmm, these dont work either. The first one gets an invalid selection error thrown, and the second one returns nil and then asks to select objects??
It never possible either it will work or "_.insert" will ask "Enter block name or [?] :"
And it natural whenever you pass any variable (value stored in it) in command that should never be within invited comma "" , otherwise it will be treated as string
@dbhunia wrote:
....(command "_.insert" "Block name" pt "" "" "")
Try with above
That depends.... Is the Block defined for uniform scaling? Whether or not it is will determine how many Enters to accept defaults for scale(s) and rotation are needed to complete the command. If it's defined for uniform scaling, that last Enter will recall the previous command [not this Insert command, but the latest command from outside AutoLisp], which, depending on what kind of command that was, could explain the select-objects prompt mentioned in Message 7.
If you might use this with different Block names, using blockname as a variable holding the Block name as in some Messages here, some of which may be defined for uniform scaling but some not, you can get around the difference by explicitly calling for the Scale as an option, in which case it will ask for only one value, and apply it to all directions:
(command "_.insert" blockname "_scale" 1 pt "")
[that's if blockname is a variable -- if using the Block name itself, that would need double-quotes around it].
You are absolutely right, every thing is relative.......
We need to ask him for sample of Drawing (with Block) & the LISP.......
@_gile wrote:
....
or like this:(command "_.insert" blockName '(4 3 6) "" "" "")
[Given the source example, that should have a decimal point rather than a space between the 4 and the 3. But it shouldn't make any difference to whether it functions, since Blocks can be Inserted at locations with non-zero Z coordinates. So if it still doesn't work, something else is going on, such as the uniform-scaling possibility, though I don't see that explaining all the difficulties described.]
@Anonymous wrote:
[in reply to @_gile's two suggestions in Message 6]
Hmm, these dont work either. The first one gets an invalid selection error thrown, and the second one returns nil and then asks to select objects??
Does the second one succeed in Inserting the Block, aside from the message? If it's a Block defined for uniform scaling, what you describe is what I would expect. The last "" in it would recall whatever outside-AutoLisp command was last used, presumably one requiring object selection, and the nil is what the (command) function always returns when finished.
As to the invalid selection message from the first one, since Insert doesn't involve selection, I wonder: did you perhaps run the code when still in some other command? If you ensure you're not in a command, and run it again, do you get the same message?
I dont think its defined for uniform scaling then. Heres the file
Yeah it was entered during another command, retried it, still no results.
@Anonymous wrote:
..... Heres the file
So apparently it's Inserting an external drawing file, not a Block defined in the current drawing. Then I don't think it can be limited to uniform scaling -- I'm not positive, but I think that can only be part of a Block definition inside a drawing.
Next question: How are you specifying what to Insert, whether directly or saved as a variable? With just the name, and if so, is it located in a folder that AutoCAD knows to look in? Or are you including a filepath, and are you sure you have it all correct? And are you using forward slashes or double backslashes as separators in the file path? [You can't use the typical filepath-separator single backslashes in AutoLisp strings, since they are used to cue special characters.] Are you perhaps using (getfiled) to get it [which should ensure that it's formatted correctly]?
I can make a list of everything I have tried. Otherwise right now I'm just passing it as a filepath, have exhausted everything I can think of with the formatting on that. Can you successfully insert the block?
check this.......
@Sea-Haven wrote:
My $0.05 I have always used -Insert
Not necessary inside a (command) function, where the command-line version rather than the dialog-box version of commands is always used, unless you force the dialog box by preceding it with (initdia).
Can't find what you're looking for? Ask the community or share your knowledge.