Jump to content

Recommended Posts

Posted

hello again,

 

I'm am continuing my experimentation with DXF codes.

I'm want to write a lisp that will change the color and linetype of an object to color 9 and hidden2.

 

If the color and linetype are NOT bylayer my code works since the DXF codes for them exists. 62 = color and 6=Ltype. I basically just change what is currently there.

 

However if they are set to Bylayer then the DXF codes do not exist and my codes fail since I can't change what doesn't exist. I need to actually add the codes. I tried one way w/ append but it didn't work. Let me show you what I have so far.

 

(defun C:MakeHidden ()
 (setq ObjHid (car (entsel "\nSelect object to make hidden")))
 (setq ObjLst (entget Objhid))

 (entmod (subst (cons 62 9)(assoc 62 ObjLst) ObjLst))
 (entmod (subst (cons 6 "Hidden2")(assoc 6 ObjLst) ObjLst))
 (entupd ObjHid))

 

I tried this to add the codes

 

 
 (append '(62 9) ObjLst)

 

but that was a failure.

Posted

Here's an alternate way- it doesn't matter if the original is Bylayer

(vlax-load-com);load com
(setq obj (vlax-ename->vla-object (car (entsel))));select an entity and turn it into an object
(vlax-put-property obj 'Color 9);change the object's color to 9
(vlax-put-property obj 'Linetype "hidden2");change the object's linetype to hidden2

Posted
Here's an alternate way- it doesn't matter if the original is Bylayer

(vlax-load-com);load com
(setq obj (vlax-ename->vla-object (car (entsel))));select an entity and turn it into an object
(vlax-put-property obj 'Color 9);change the object's color to 9
(vlax-put-property obj 'Linetype "hidden2");change the object's linetype to hidden2

 

You're getting pretty hooked on this VL stuff... :P

Posted
You're getting pretty hooked on this VL stuff...

I find it's much simpler for situations like this... but it can be a bear for others. I wish I knew more about the vla- functions. Vlide helps, but if you don't know what you're looking for it's kinda hard to leaf through to find a method...

Posted
I find it's much simpler for situations like this... but it can be a bear for others. I wish I knew more about the vla- functions. Vlide helps, but if you don't know what you're looking for it's kinda hard to leaf through to find a method...

 

True, sometimes you just have to try to put 2+2 together :geek:

Posted
I find it's much simpler for situations like this... but it can be a bear for others. I wish I knew more about the vla- functions. Vlide helps, but if you don't know what you're looking for it's kinda hard to leaf through to find a method...

 

 

yeah i'd like to learn more about the vl- functions but I don't know where to start. I just kind of pick stuff up here and there. I'm going to use the ones you mentioned. thanks alot.

Posted
yeah i'd like to learn more about the vl- functions but I don't know where to start. I just kind of pick stuff up here and there. I'm going to use the ones you mentioned. thanks alot.

 

There is a lot of info in the Visual LISP Help files, but most are written for VBA, so you have to make a connection.

Posted
Here's an alternate way- it doesn't matter if the original is Bylayer

(vlax-load-com);load com
(setq obj (vlax-ename->vla-object (car (entsel))));select an entity and turn it into an object
(vlax-put-property obj 'Color 9);change the object's color to 9
(vlax-put-property obj 'Linetype "hidden2");change the object's linetype to hidden2

 

I tried your code and I got this error at first

; error: no function definition: VLAX-LOAD-COM

 

I removed it and now it seems to work fine

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