for pnts in geo.prims(): if pnts.number() == 5: geo.deletePrims(pnts,keep_points=False)
Delete Prim without List
4692 17 1- _Christopher_
- Member
- 766 posts
- Joined: April 2014
- Offline
- Nima
- Member
- 471 posts
- Joined: Nov. 2013
- Offline
- _Christopher_
- Member
- 766 posts
- Joined: April 2014
- Offline
- Nima
- Member
- 471 posts
- Joined: Nov. 2013
- Offline
- _Christopher_
- Member
- 766 posts
- Joined: April 2014
- Offline
- _Christopher_
- Member
- 766 posts
- Joined: April 2014
- Offline
- pezetko
- Member
- 387 posts
- Joined: Nov. 2008
- Offline
fcList is the result of the “append” method not list itself. You want to
https://docs.python.org/2/tutorial/datastructures.html [docs.python.org]
print(FaceList)
https://docs.python.org/2/tutorial/datastructures.html [docs.python.org]
- _Christopher_
- Member
- 766 posts
- Joined: April 2014
- Offline
pezetko
fcList is the result of the “append” method not list itself. You want toprint(FaceList)
https://docs.python.org/2/tutorial/datastructures.html [docs.python.org]
Yes, but I put it in a variable because it was not printing a list of the prims or points I stored in the list when using “FaceList” ?
【T】【C】【S】
- Nima
- Member
- 471 posts
- Joined: Nov. 2013
- Offline
- _Christopher_
- Member
- 766 posts
- Joined: April 2014
- Offline
NimaChristopher_R
for pnts in geo.prims():
if pnts.number() == 2:
strPrm = geo.deletePrims(,keep_points=False)
fcList = FaceList.append(strPrm)
print(fcList)
geo.deletePrims(,keep_points=False) returns a None hence if you try to print it nothing will get.
Originally what you're telling I sorta knew would happen but I was hoping I could put it in a list; unless you know of another solution ?
You wouldn't happen to know if destroy() in PrimGroup keeps the prim/points in the group but removes them from the geometry or completely removes the prim/group from the group and geometry ?
Edited by _Christopher_ - Nov. 26, 2017 01:16:38
【T】【C】【S】
- Nima
- Member
- 471 posts
- Joined: Nov. 2013
- Offline
- _Christopher_
- Member
- 766 posts
- Joined: April 2014
- Offline
If I'm doing this right;
This is storing primitive #5 in a list, but why is the first item in the list None and the second item in the list primitive #5; shouldn't there not be a first item in the list ? The second last line gives an error ?
if pnts.number() == 5: tt = FaceList.append(pnts) #strPrm = geo.deletePrims([pnts],keep_points=False) strGroupPrim = hou.PrimGroup strGroupPrim.add(pnts) print(tt)
This is storing primitive #5 in a list, but why is the first item in the list None and the second item in the list primitive #5; shouldn't there not be a first item in the list ? The second last line gives an error ?
Edited by _Christopher_ - Nov. 26, 2017 10:30:05
【T】【C】【S】
- Nima
- Member
- 471 posts
- Joined: Nov. 2013
- Offline
strGroupPrim = hou.PrimGroup isn't instantiate new object (try print id() for both).
It is a new name for hou.PrimGroup instead of typing hou.PrimGroup over and over again.
This is why you get unbound method error because you don't create a real object of the class.
In order to create new instance of the class you should type strGroupPrim = hou.PrimGroup().
However you can't instantiate directly because it raises up an attribute error and says No constructor defined!
hou.PrimGroup is a class that lets you to modify and manipulate a group so it doesn't make sense to have ability of creating objects directly from this class.
You should create a new primitive group that returns hou.PrimGroup in this case you can use all of hou.PrimGroup methods without any problem.
Let's complete your code:
Now you have a primitive group called Mark_for_Delete and you can use in a delete SOP node.
If you uncomment the three last line, primitives number 5 and 10 will delete as well.
Hope this helps.
It is a new name for hou.PrimGroup instead of typing hou.PrimGroup over and over again.
This is why you get unbound method error because you don't create a real object of the class.
In order to create new instance of the class you should type strGroupPrim = hou.PrimGroup().
However you can't instantiate directly because it raises up an attribute error and says No constructor defined!
hou.PrimGroup is a class that lets you to modify and manipulate a group so it doesn't make sense to have ability of creating objects directly from this class.
You should create a new primitive group that returns hou.PrimGroup in this case you can use all of hou.PrimGroup methods without any problem.
Let's complete your code:
node = hou.pwd() geo = node.geometry() # Add code to modify contents of geo. # Use drop down menu to select examples. group = geo.createPrimGroup("Mark_for_Delete") FaceList = [] # Declare that FaceList is an empty list for pnts in geo.prims(): if pnts.number() == 5 or pnts.number() == 10: FaceList.append(pnts) #strPrm = geo.deletePrims([pnts],keep_points=False) group.add(pnts) print FaceList[len(FaceList) - 1].number()
Now you have a primitive group called Mark_for_Delete and you can use in a delete SOP node.
If you uncomment the three last line, primitives number 5 and 10 will delete as well.
Hope this helps.
Edited by Nima - Nov. 26, 2017 19:28:50
- _Christopher_
- Member
- 766 posts
- Joined: April 2014
- Offline
hou.PrimGroup is a class that lets you to modify and manipulate a group so it doesn't make sense to have ability of creating objects directly from this class.
Can you create objects directly from this class ?
You can't instantiate directly without an error unless you populate a new class instance with values; and that is only done by calling a method on a class instance with the type which want to return ?
【T】【C】【S】
- Nima
- Member
- 471 posts
- Joined: Nov. 2013
- Offline
- _Christopher_
- Member
- 766 posts
- Joined: April 2014
- Offline
- Nima
- Member
- 471 posts
- Joined: Nov. 2013
- Offline
tt is a short name for geo.createPoint if you don't put parentheses however if you try to run your code it's not work because createPoint wants argument but you don't tell python what they are (even your function hasn't parameters)
in these two manners you can do:
in these two manners you can do:
#First Manner: tt = geo.createPoint() #If you put parentheses at the front of createPoint, object will create. bb = tt.number() #shouldn't put any parentheses at the front of tt print bb #Seccnd Manner: tt = geo.createPoint #If you don't put parentheses at the front of createPoint, object won't create bb = tt().number() #should put parentheses at the front of tt print bb
- _Christopher_
- Member
- 766 posts
- Joined: April 2014
- Offline
-
- Quick Links