AutoCAD Visual LISP / AutoLISP :: Copy Variable Contents Into Attribute Tag In Selection Set Of Blocks

Aug 25, 2011

I have to obtain a selection set of blocks (by window selection and/or single-picks if the user desires) and then an attribute value which I have previously assigned to a variable called TAGVAL to the attribute tag name called PART in that selection set of blocks.

I found a cool routine called RepAtt, but it isn't quite set up to do what I need...
 
(defun RepAtt (Tag / SourceBlk ValueToCopy SelSet) (vl-load-com) (if (setq SourceBlk (car (entsel "
Select Source Block:"))) (progn (mapcar '(lambda (p) (if (equal (vla-get-tagstring p) Tag) (setq ValueToCopy (vla-get-textstring p)) ) ) (vlax-invoke (vlax-ename->vla-object SourceBlk) 'GetAttributes ) ) (ssget ":L" '((0 . "INSERT") (66 . 1))) (vlax-for DesBlock (setq SelSet (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object)) ) ) (foreach att (vlax-invoke DesBlock 'GetAttributes) (if (equal (vla-get-tagstring att) Tag) (vla-put-textstring att ValueToCopy) ) ) ) (vla-delete SelSet) ) ) ) (RepAtt "WIDGET");<-- Tag Name

View 1 Replies


ADVERTISEMENT

AutoCAD Visual LISP / AutoLISP :: Copy Block Attribute Data To A Selection / Group Of Blocks

Apr 15, 2011

I found a lisp to get block attribute data to a other block. See attachment. I can only apply it to one block. I like to apply it to selected blocks or blocks in a group. Is this possible?

View 9 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Update Block Attribute With Variable

Mar 8, 2013

I would like to create a lisp that does the following:

Update a titleblock attribute with a $variable.

The titleblockname is variable / not static.

The attribute is not variable / Static, DW_SCALE

The titleblock is always places on the same layer, BL$4----

The (custom)-plotscale is stored in the $var "gvpsc".

I've tried to ajust the following lisp code. But I couldn't extract the part I need.

The problem is, the code checks all the layouts and updates all the titlblocks one by one.

Truely a good code. 

The only problem is, I don't have multiple layouts and I have a variable titleblock name.

Here is to code i've tried to convert to something I could use.

(defun C:UPD-DPC () (setvar "cmdecho" 0) (setq blkname "DPC-STEMPEL");(getstring "
Enter the name of block to update: ")) (setq att1 "DW_DATE");(strcase(getstring "
Enter the name of the attribute to change: "))) (setq newatt (strcase(getstring "

[Code] ....

View 9 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Transfer Attribute Block Values To Another Attribute Blocks

Jul 3, 2012

I wanna transfer my attribute block values to another attribute text blocks , is there any lisp for that?

Is there a possibility for sum tag values of choice attribute blocks to inside of another attribute text block ?

View 2 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Copy One Attribute Value?

Nov 2, 2012

i want to select a block and the lisp copies TAG1 into my clipboard (i want to paste it in excel)

View 9 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Get Attribute Values From Multiple Blocks With Same Name?

Mar 21, 2013

This time I'm wrestling with getting the values from multiple blocks. The blocks all have the same name but at least the attributes have names this time. Each block have exactly 4 attributes, like: att1 (a number representing chronological order), att2 (some data), att3 (the actual date as a string of when the data was added), att4 (some more data)

I need to get and store the attribute's values. I was hoping to make a selectionset of the blocks and step through using the chronological order number.

At this point I have tried several combinations of foreach and ssget "x" (list (cons 2 MYBLOCK)), but I keep getting errors that I'm sure are telling me that I'm not passing the correct information to the function for iterating through. I'm banging my head.

(DEFUN c:GFOR (/ ATTLST REVBLK CNT CNT1 BLK RBLK ATTVAL ATT REV#)
(SETQATTLST(LIST "R#" "INIT" "DATE" "DESC")REVBLK(ssget "x" (list (cons 0 "INSERT") (cons 2 "REVISION")))CNT0CNT10 )
(vlax-ldata-put "dict" "RevTotal" (BLKCNT "REVISIONS")) (FOREACH BLK REVBLK (SETQ RBLK (ssname BLK CNT1)) (setq ATTVAL (mapcar '(lambda (x) (vla-get-TextString x)) (vlax-invoke (vlax-ename->vla-object RBLK) 'GetAttributes))) (foreach ATT ATTLST (SETQ REV# (STRCAT "REVISION" (1+ CNT)))
(vlax-ldata-put "dict" REV# (member ATTVAL)) (setq CNT (1+ CNT)) ) (SETQ CNT1 (1+ CNT1)) ) (PRINC))

View 9 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Add Attribute To Selected Blocks (XY Coordinates)

Nov 30, 2012

i have found the following lisp in a previous thread: (shows XY coordinates of the selected blocks)

(defun C:MyFunc (/ ss Index Ename Lst)
(while (or (not ss) (= 0 (sslength ss))) (setq ss (ssget '((0 .
"INSERT")))))
(if ss

[Code]....

I want this information to be added to the blocks as hidden attributes so that i can extract them by attout. The work to be done is : attout to excel, autofill an attribute (numbering) then attin.

but my problem is that i cant think of a way to number those blocks IN ORDER (ie top to bottom or left to right) unless by sorting them in excel first by their x or y coordinates

View 9 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Select Blocks By Attribute Layer

Dec 16, 2013

I would like to select blocks based on the layer of one or more attributes.  The obvious method would be to isolate that layer and select the ones with attributes that display. But many of the values are empty!

View 9 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Copy Block Increase Attribute Number

Jun 19, 2012

I have a simple hexagon block with one attribute, i need to be able to copy it and as i do it increases the number by one.

the Block name is note1-2006 the attribute name is NOTENUM. I have tried using some other Lisps but i cant ge them to work. Sometimes i have to put 40 of these on a sketch i hate copying and changing the attribute by one everytime. so it would be nice to copy and as i pick mutliple spots it increase number. Dont know if there is a way to ask user to keep same number or increase. This would save me so much time.

View 9 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Routine For Changing Attribute Tag Width Globally In Blocks

Jul 15, 2013

Any lisp routine for changing the text width of all the attributes in a block globally. I want to change it from 1.0 to 0.8. I have attached a symbol where the attritube tags will be the same.

View 2 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Copy Selection Set From P1 To P2?

Feb 13, 2012

I need to copy a selection set from p1 to p2.to do this I wrote the following

(defun c:test () (setq sel (ssget)) (setq p1 (getpoint "
Origine: ")) (setq p2 (gettpoint p1 "
Destination: ")) (command "_.copy" sel "" p1 p2))
 
works, but this way I can not see objects dynamically attached to the mouse cursor.

To visualize this effect, I noticed that I can use:

 (command "_.copy" sel "" pause pause)
 
but in this way I can not save the variables p1 and p2: I need for these, subsequently in the rest of thefunctions lisp.

View 4 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Attribute Blocks - Change 1st Tag Values Automatically According To 2nd Values

Jul 18, 2013

I have an attribute blocks and this att block has two tag values , is there a simple code for to change 1st tag values automaticly according to  2nd values ?

for example :

1st tag (50x50) - 2nd tag ( 100 )    ==> 50x50-100

if i enter 201 valuse to 2nd tag then 1 st tag has to change as 100x100

if i enter 501 valuse to 2nd tag then 1 st tag has to change as 150x510

I attached a jpg file for explain much better

View 9 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Contents - Check How Many Elements Are Same

Jul 10, 2012

I have a List with values shown

A=(0 0.1 0.1 0.1 0.2 0.2 0.3 0.3)

I have to check that how many elements are the same and which one is the first and the last in the same elements.

Like 1.0 is the number 1 element and third element the the 3rd element. how can i Manipulate is Visual Lisp.

View 9 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Convert Attribute Tag Into Attribute Value?

Dec 8, 2011

Background: Someone exploded an attribute block and copied it hundreds of times throughout a project, each time changing the Attribute Tag to match the Value they expected to appear in their drawing.  The drawing must be xrefed, so the attribute definitions do not appear.

(There is only 1 attribute in the block.) 

Proposed Solutions:

1:AutoLISP routine which copies Tag data from Attribute Definition into Value of Attribute Block:

Prompt-Select Attribute Definition

Copy Tag data

Prompt-Select Attribute Block

Paste data into Value

(Allow repeat to speed workflow)(*PREFERRED*)

2:AutoLISP routine which copies Tag data from Attribute Definition into Default Value and creates a new Block:

Prompt-Select Attribute Definition

Copy Tag data

Paste data into Default Value

Create New Block

(Select Multiple Objects)(Creates tons of new blocks which are messy)

View 3 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Copy Shortcut C Doesn't Copy Multiple But Typing In COPY Does

Aug 23, 2013

I have a keyboard shortcut for Copy (see directly below). This command doesn't copy multiple. But if I type "Copy" at the comment prompt (AutoCAD 2013) the copy multiple is the default. Copymode is already set to "0".

(DEFUN C:C()
(setvar "SNAPMODE" 1)(COMMAND "_COPY")
(PRIN1)
)

View 4 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Asterisks In Variable Name?

Nov 15, 2013

I was just looking through one of Lee Mac's tutorials and I'm curious about something.

Here's a link to the tutorial I'm talking about.

[URL]

What is the purpose of the asterisks in the following code (marked in RED):

(if (not *ans*) (setq *ans* "Alpha"))
(initget "Alpha Beta Gamma")
(setq *ans*
  (cond
    (
      (getkword
        (strcat "

[code]....

View 4 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Set TARGET Variable

Apr 23, 2013

I am trying to change the current TARGET variable to 0,0,0. If the variable is not changed is causes problems with plotting. I have the VBA that will change the TARGET variable. VBA works no problems. I am wanting to replicate in LISP because I do not want to have to convert to .NET and do not want to make sure the user has the VBA loded on thier system.  Here is what have so far.

;;;Get active viewport
(setq avp (vla-get-ActiveViewport (vla-get-ActiveDocument (vlax-get-acad-object))))
;;;Get current TARGET variable
(setq CTarget(vla-get-Target avp))

Here is the problem. Is changing or putting the vaiable.I have tried

(vla-put-Target avp (vlax-3D-point '(0.0 0.0 0.0)))

and

(vla-put-Target avp (vlax-make-variant (vlax-3D-point '(0.0 0.0 0.0))(vlax-variant-type  CTarget)))

They either error out or nil with no change. I have even tried to locate it in the Dictionaries.

View 5 Replies View Related

AutoCAD Visual LISP / AutoLISP :: How To Get Net Volume Results Into Variable

Nov 11, 2011

There is a command in autocad that will get a Bounded Volume from a closed polyline and a volume surface (command "AeccReportSurfBoundedVolume").  It reports the results to the screen. How to get the "Net Volume" results in to a variable using Lisp? 

Maybe a lisp routine that gets information from the text screen.  That would not be ideal but I could work with that.

View 2 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Subtracting List From A Variable

Sep 17, 2013

I've created a list and want to subtract all the values within it from another variable, and assign it to a new variable. How do I do it?

Basically, I ask for ground level (assigned to variable G1), and then any number of depths beneath that (assign to list LVLLIST), and I want to return the value of the bottom point. So it's all the values in LVLLIST added together and subtracted from G1. And assign it to a new variable BASE.

For example,

G1 = 650.00
LVLLIST = (1.23 23.26 0.13 50.23)
(setq BASE (- G1 LVLLLIST))

View 2 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Creating Variable Names

Nov 28, 2008

How to write some code which could create variable names like var1, var2, var3, etc. I need to do this because I have a large number to create and the actual number is variable and unknown.

Instead of manually writing a large number of line like

(setq var1 value1)
(setq var2 value2) etc

I used to be able to put 1 line in a loop to create and assign a large number of variables. I remember that it involved the use of the set (not setq) and read functions.

View 9 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Program Variable Names?

Feb 28, 2012

Is there anyway to program variable names?

What I was thinking of was in a loop some times I need multiple sets of similar variables but am not sure how many sets I am going to need. I would like to be able to increment the variable names each time the loop runs.

View 2 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Command Line Variable

Feb 7, 2013

Somehow, I manage to turn of one variable that display errors on command line.

For example:

(seq a 6)

suppose to return, on command line, something like:

error no function definition: SEQ

View 9 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Multileader Scale Variable

Oct 10, 2008

A2008. Is there a setvar, setenv, registry entry etc. that can be used to change the scale of Multileaders with annotative off to have the same effect that DIMSCALE has on Q leaders? I want to have a single scale-independent Multileader style and modify it on the fly along with DIMSCALE and LTSCALE. I'd use Qleader but UCS's do odd things to text position and orientation.

View 4 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Passing String As Variable?

Jul 9, 2013

I would like to use a string as a variable if this is possible. I've got:

new-pl-lay (as a variable that holds layer name "UGL_PL_NEW")

first-cable (as a string that holds "new-pl-lay")

I'd like set the current layer to "UGL_PL_NEW" by using the first-cable string.

Something like:

(command "_.layer" "m" (read first-cable) "")

View 8 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Convert Variable To Command Name?

Mar 12, 2012

I am trying to shorten my code by using the variable as the command name. Is that possible to do?

;; instead of this(cond ((eq USER_INPUT_ANSWER "blk-cdtree-01-06")(C:blk-cdtree-01-06)) ((eq USER_INPUT_ANSWER "blk-cdtree-01-08")(C:blk-cdtree-01-08)) ((eq USER_INPUT_ANSWER "blk-cdtree-01-10")(C:blk-cdtree-01-10)) ((eq USER_INPUT_ANSWER "blk-cdtree-01-12")(C:blk-cdtree-01-12)));; do something like this(C:blk-cdtree-(substr USER_INPUT_ANSWER 11))

View 8 Replies View Related

AutoCAD Visual LISP / AutoLISP :: How To Save Filename As Variable

Oct 20, 2011

how to write a lisp command, or function, that will save my newly created drawing with a file name is that is called up from a variable.

For example:

(setq filename variable)
(command "saveas" "r14" "filename")

and i would want the outcome to be:  variable.dwg, rather than filename.dwg. I have tried numerous different ways of doing this with command prompt and cant seem to get anything to stick.  Everything that works just creates a file named "filename.dwg", which is not what i want to do.

View 9 Replies View Related

AutoCAD Visual LISP / AutoLISP :: How To Check If System Variable Is Read Only

Nov 22, 2012

How do I check, with LISP, if a System Variable is read only? In particular ANNOTATIVEDWG. This one is read/write when there are no annotative objects in a drawing, but read-only if there are.

View 7 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Can't Append Registry To Value Of SAVEFILEPATH Variable

Oct 2, 2012

How come I can't modify the following registry key to the SAVEFILEPATH variable?
 
(vl-registry-write "HKEY_CLASSES_ROOT\SOFTWARE\Treadstone\File Sweeper" "NETWORK_LOCATION" SAVEFILEPATH)

View 1 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Replace Drive By Environment Variable?

Apr 26, 2012

I want to know if it's possible to replace a drive by an environment variable in a search path in the profile. For example:

to replace C:Program FilesAutodeskAutoCAD Mechanical 2012Acadm by %LOCAL DRIVE%Program FilesAutodeskAutoCAD Mechanical 2012Acadm. 

View 5 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Storing Variable / Associate / Recall

Oct 24, 2013

I am looking for some way to store variables. For example in loop I want to

Enter a number
1

Enter hatch pattern
Ansi31

Enter a number
3

Enter hatch pattern
Ansi32

Enter a number
1

Enter hatch pattern <Ansi31>
Enter
Enter a number.... etc.

View 9 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Dimstyle Break Size Variable?

Aug 28, 2009

I want to set the break size in all of my dimstyles but I can't find a system variable for it. know what it is or how else to set it?

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved