Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Change Properties of Inserted Bock

19 REPLIES 19
Reply
Message 1 of 20
conveyor11
461 Views, 19 Replies

Change Properties of Inserted Bock

I am trying to insert a block with one of the block properties preset to a global setting in the menu. My idea was to have the menu button insert the block, select the inserted block and then set the block properties. I know how to insert the block and I have the new values for the properties, but how do you select the last inserted item into a drawing and get the property information?
19 REPLIES 19
Message 2 of 20
Anonymous
in reply to: conveyor11

What property are you trying to change?
Is it a dynamic (block) property?
(entlast) returns the last object.
But more information might be helpful to figure out what you are attempting to do.
Message 3 of 20
conveyor11
in reply to: conveyor11

I have a dynamic block property named "Width". Width is a variable in all my blocks. All I want to do is set the menu "Width" variable to say 18 and all the blocks I insert will come in 18 wide.
Message 4 of 20
Anonymous
in reply to: conveyor11

You'll need the attached file to change dynamic properties.

Then your macro would be something like:

Insert;MyDynBlock;\1;1;0;(chgdynprop (entlast) "Width" 18.0)
Message 5 of 20
conveyor11
in reply to: conveyor11

I know I need to place the dynblock.lsp in one of the AutoCAD search paths. But, do I need to break the attached file apart so I have a lisp called chgdynprop?
Message 6 of 20
Anonymous
in reply to: conveyor11

No, just load the entire file at startup.
You can add (Load "dynblock") to acaddoc.lsp, or to your .mnl file.
You can also add it to your startup suite with the command APPLOAD.


wrote in message news:5607004@discussion.autodesk.com...
I know I need to place the dynblock.lsp in one of the AutoCAD search paths. But, do I need to break the attached file apart so I
have a lisp called chgdynprop?
Message 7 of 20
Anonymous
in reply to: conveyor11

Allen,

Maybe a minor point regarding this function.

(defun ssdblk (effname / ssx ssf c en)
(setq ssx (ssget "X" (list (cons 2 (strcat effname ",`*U*")))))
(setq ssf (ssadd)
c 0
)
(if ssx
(repeat (sslength ssx)
(setq en (ssname ssx c)
c (1+ c)
)
(if (= (print (vla-get-effectivename (vlax-ename->vla-object en))) effname)
(ssadd en ssf)
)
)
)
ssf
)

This line (setq ssx (ssget "X" (list (cons 2 (strcat effname ",`*U*"))))) doesn't
make sense because you cannot do a filtered selection set based on effective name.
Discussed here previously. What you are doing, in effect, is selecting all anonymous
*U blocks and then post-processing.

Joe Burke


"Allen Johnson" wrote in message
news:5606861@discussion.autodesk.com...
You'll need the attached file to change dynamic properties.

Then your macro would be something like:

Insert;MyDynBlock;\1;1;0;(chgdynprop (entlast) "Width" 18.0)
Message 8 of 20
Anonymous
in reply to: conveyor11

Mr. Burke,
Your point is EXACTLY correct. You can't filter on effective names.
But until you change a dynamic block property from its default, it keeps its effective (or AutoCAD block) name.
As you can see from the screen list below the first dynamic block does NOT have an anonymous name "*U####", but the second one does.
So if you do not include the effname in the filter, the routine will not find the first (unmodified) insert.

BLOCK REFERENCE Layer: "S-ANNO-DIMS"
Space: Model space
Handle = 55a7
Block Name: "WFSection"
at point, X=581'-3 1/4" Y=405'-10 5/8" Z= 0'-0"
X scale factor: 1.000
Y scale factor: 1.000
rotation angle: 0.0000
Z scale factor: 1.000
InsUnits: Inches
Unit conversion: 1.000
Scale uniformly: No
Allow exploding: Yes
Beam Sizes: Unlisted Size
Section Type: WF Section
WT Height: 0'-2 1/8"

BLOCK REFERENCE Layer: "S-ANNO-DIMS"
Space: Model space
Handle = 5568
Block Name: "WFSection"
Anonymous Name: "*U72"
at point, X=580'-1 7/8" Y=405'-10 5/8" Z= 0'-0"
X scale factor: 1.000
Y scale factor: 1.000
rotation angle: 0.0000
Z scale factor: 1.000
InsUnits: Inches
Unit conversion: 1.000
Scale uniformly: No
Allow exploding: Yes
Beam Sizes: W 40 x 531 x 16.5
Section Type: WF Section
WT Height: 1'-9 1/8"



This line (setq ssx (ssget "X" (list (cons 2 (strcat effname ",`*U*"))))) doesn't
make sense because you cannot do a filtered selection set based on effective name.
Discussed here previously. What you are doing, in effect, is selecting all anonymous
*U blocks and then post-processing.

Joe Burke
Message 9 of 20
conveyor11
in reply to: conveyor11

I put the lisp in one of the search paths and added the lisp to the cui file. However, when I click on the menu button, the block inserts, but I receive this message. "Command: (chgdynprop (entlast) "Width" 24) ; error: Automation Error. Invalid".
Message 10 of 20
conveyor11
in reply to: conveyor11

Here is the command line in the menu

^C^C^P-LA;M;belt;C;5;;;-INSERT;test24;\1;1;0;(chgdynprop (entlast) "Width" 24)

test24 is the name of the block, "Width" is the lookup paramater name.

With this line, I am getting this error.
Command: ; error: Automation Error. Invalid input
Message 11 of 20
Anonymous
in reply to: conveyor11

Try 24.0 (a real number, not an integer).
Message 12 of 20
conveyor11
in reply to: conveyor11

Same result with the 24.0

Command:
Enter block name or [?] :

Units: Inches Conversion: 1.0000
Specify insertion point or [Basepoint/Scale/X/Y/Z/Rotate]:
Enter X scale factor, specify opposite corner, or [Corner/XYZ] <1>:
Enter Y scale factor :

Specify rotation angle <0>:

Command: ; error: Automation Error. Invalid input

Could it be something in the lisp? When I typed tbd at the command line, the tbd command worked. However, the other commands do not.
Message 13 of 20
conveyor11
in reply to: conveyor11

Do you have a simple example you can post? Maybe I am just missing little detail.
Message 14 of 20
Anonymous
in reply to: conveyor11

Post your block. Maybe that will give me some idea. I noticed that you said it's a "Lookup" property, so maybe the value is a
string?
Without seeing your block, I'm guessing. Place your dynamic block within a container drawing and post that drawing.
Message 15 of 20
conveyor11
in reply to: conveyor11

For some reason, I can't post the file. I have tried both dwg and zip formats. Do you have a general e-mail address I can send it to?
Message 16 of 20
Anonymous
in reply to: conveyor11

Give me your address and I'll send it to you.
Message 17 of 20
conveyor11
in reply to: conveyor11

test Message was edited by: conveyor1
Message 18 of 20
Anonymous
in reply to: conveyor11

For lookup tables you need a string:

(chgdynprop (entlast) "Width" "36")
Message 19 of 20
conveyor11
in reply to: conveyor11

For those of you who are interested, here is the final code I put in the menu.

-INSERT;2PDPL;\;;\(chgdynprop (entlast) "Width" (strcat width))

2PDPL is the block name

Here is the code to set the width vairable

^C^C^P(setq width "18 NW")

Thanks for the help.
Message 20 of 20
conveyor11
in reply to: conveyor11

If any one is having an issue with 2008, check out this forum for the solution.

http://discussion.autodesk.com/thread.jspa?messageID=5535377

I just added (vl-load-com) to the first line of the lisp.

Thank You

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost