Jump to content

Please help with LM:SetAttributeValues Routine...


lamensterms

Recommended Posts

Hey guys,

 

I've got this routine which is composed of 2 other routines which have been provided by Lee Mac and Carry.

 

The idea is for the routine to read a ProSteel attribute from a ProSteel element (Carry's routine), and assign that attribute to an attribute value in my title block (Lee Mac's routine).

 

Code:

 

(defun LM:SetAttributeValues ( block lst / elist item )
   (if
       (eq "ATTRIB"
           (cdr
               (assoc 0
                   (setq elist
                       (entget (setq block (entnext block)))
                   )
               )
           )
       )
       (if (setq item (assoc (strcase (cdr (assoc 2 elist))) lst))
           (progn
               (if (setq elist (entmod (subst (cons 1 (cdr item)) (assoc 1 elist) elist)))
                   (entupd (cdr (assoc -1 elist)))
               )
               (LM:SetAttributeValues block lst)
           )
           (LM:SetAttributeValues block lst)
       )
   )
)






(defun c:FC2TB  (/ ss num con ent3A ent3B acadapp shapeinfo CPOS NPOS acadApp)

;--------------------------Read Data From Element------------------------------
(prompt "\nSelect ELEMENTS:")(princ)
(setq ss (ssget "x" '((0 . "KS_SHAPE,KS_PLATE,KS_BOLT,KS_BENDSHAPE,KS_ARCSHAPE,KS_ARCPLATE,KSBENDPLATE,Ks_VolBody"))));8=Name Layer 0=ks_object
(setq num (sslength ss));n° object
(setq con 0)
(repeat num  
(setq ent3A (ssname ss con)) ;       (entsel "\nSelect BOLT: "))
(setq ent3B ent3A)
(setq acadapp (vlax-get-acad-object))
(setq shapeinfo (vla-getinterfaceobject acadapp "PSCOMWRAPPER.Ks_ComShapeInfo"))    
(vlax-invoke-method shapeinfo 'setobject  (vlax-ename->vla-object ent3A))
(vlax-invoke-method shapeinfo 'getinfo);ritrova le informazioni nel database
(setq shapeinfo (vla-getinterfaceobject acadApp "PSCOMWRAPPER.Ks_ComShape"))
(setq shapeinfo (vlax-ename->vla-object ent3B))   
(setq PSCOUNT (vlax-get-property shapeinfo 'TotalCount))  ;Position Number
(vlax-release-object shapeinfo)   
(setq shapeinfo nil)
(setq acadApp nil)(princ)
(setq con (1+ con)))

;*****************************************************************************

(defun c:UPDATETITLEBLOCK ( / ss data i )
   (if (setq ss (ssget "_X" '((0 . "INSERT") (66 . 1))))
       (progn
           (setq data
              '(
[b]                    ("COUNT" . PSCOUNT)[/b]
               )
           )                  
           (repeat (setq i (sslength ss))
               (LM:SetAttributeValues (ssname ss (setq i (1- i))) data)
           )
       )
   )
   (princ)
)

(c:UPDATETITLEBLOCK)

)

 

What I'm struggling with is feeding the PSCOUNT symbol into Lee Mac's routine (code highlighted bold).

 

Just wondering if someone can please help me understand where I am going wrong.

 

Thanks a lot for any help.

Edited by lamensterms
Link to comment
Share on other sites

Are you actually meaning a Attribute value ? The tag is the description/name of a attribute two different things.

 

Simply you choose the block match the block tag name and update the attribute value.

 

A couple more questions where is your title block modelspace or in a layout makes a difference also. Simply if in a layout go into a veiw pick "Bolt" title block updates very easy.

Link to comment
Share on other sites

Hi BigAl,

 

Thanks for the reply.

 

Yes, sorry about that, I do mean attribute value.

 

The title block is in model space.

Link to comment
Share on other sites

That could be an issue there.

If standards determine that your title block should be in model space than so be it,

but typically the geometry goes into model space and the annotative objects such as labels, stamps, titleblocks, leaders, text callouts, etc etc etc, all go into paperspace, in conjunction with a viewport that has been cut to include the section of the model you are working with.

If you can change to this set up it may be beneficial in the long wrong, if your set-up isn't your own doing or your own call, then excuse my post please just trying to be of assistance. :)

Link to comment
Share on other sites

Hi Bhull1985,

 

Thanks for the reply.

 

I do appreciate your input, but our protocols are really dictated to us by the offices we collaborate with, and the set ups they are used to. Also, I'm pretty sure (but not certain) that the current configuration we use is relied on by the ProSteel addon package we use. So unfortunately we are quite limited in how much we can change our procedures.

 

Thanks again.

Link to comment
Share on other sites

Haha, that would have been a great idea to include that in the original post. I'll post back with the error I've been getting, when I get to work (in about 11 hours).

 

Thanks again guys, to be continued.

Link to comment
Share on other sites

Currently your code is quoting the list, so it's not evaluating PSCOUNT. Note the apostrophe in front of the parenthesis.

[color=black](setq data [b][color=red]'[/color][/b](("COUNT" . PSCOUNT)))[/color]

 

What you would need to do in this case is

(setq data (list (cons "COUNT" PSCOUNT)))

 

A caution, you will need PSCOUNT to be a string, not an integer or a real. If the value is an integer, convert it with itoa, or if a real, rtos.

Link to comment
Share on other sites

Hey everyone,

 

Back again.

 

Clint, your suggestion worked perfectly, thanks a lot for providing that. I did have to convert PSCOUNT to a string using RTOS.

 

For the sake of record keeping, the error code I was receiving prior to applying Clint's solution was "error: bad DXF group: (1 . PSCOUNT)".

 

Thanks again for all your help and advice guys.

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...