Jump to content

Creating an Attribute Value from a specified prefix and the file name.


Da Ballz

Recommended Posts

I'm trying to build a string using a specified prefix (user defined variable) and the file name. I then want to set the string as a variable and pass it to an attribute as the new value. Here is a bit of the code so far:

 

(if (setq ss (ssget "X" '((0 . "insert")(2 . "Drawing_Sheet_*,"))))

(progn

(while (> (sslength ss) 0)

(setq ent (ssname ss 0))

(ssdel ent ss)

 

(setq pre "100-")

(setq drawing (substr (getvar "dwgname") 1 (- (strlen (getvar "dwgname")) 4)))

(setq drawingname (strcat pre drawing))

 

(ATT:REPLACE ent '( ;ATT:REPLACE works, it's define above in the larger function

 

("Drawing_Number" . "drawingname")

 

)

 

The problem is that I'm still not sophisticated enough to understand how to pass the variable here. When I try to pass drawingname to the attribute value for the attribute "Drawing_Number", I don't get the concatenated string I'm expecting. It should be 100-"the file name", but I'm obviously doing something wrong in passing the variable. Obviously, the only thing that will happen is the value will literally become drawingname, not the value of the variable drawingname.

 

If I remove the quotes from "drawingname", I get the error: bad DXF group (1 . DRAWING NAME). It's something very simple I can feel it.

Edited by Da Ballz
Link to comment
Share on other sites

A slight suggestion rather than worry about deleting from selection set just scroll through all items.

 

(if (setq ss (ssget "X" '((0 . "insert")(2 . "Drawing_Sheet_*,"))))
(progn
(setq x -1)
(while (setq ent (ssname ss (setq x (+ x 1))))

;my replacement code example
(setq oldtag1 "Drawing_number") ;attribute tag name
(foreach att (vlax-invoke (vlax-ename->vla-object (ssname SS x )) 'getattributes)
       (if (= oldtag1 (strcase (vla-get-tagstring att)))
       (vla-put-textstring att drawingname) 
       ) ; end if
)

 

 




			
		
Link to comment
Share on other sites

(while (setq [color="blue"]ent [/color](ssname ss (setq x (+ x 1))))

(foreach att (vlax-invoke (vlax-ename->vla-object [color="red"](ssname SS x )[/color]) 'getattributes)

 

Since that you already have the variable ent that obtains the entity name , so there is no need to re-retrieve the entity name once again ;)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...